//Begin_Html
/*
<img src=".gif">
*/
//End_Html
#include "TBits.h"
#include "TGeoManager.h"
#include "TGeoShape.h"
#include "TGeoVolume.h"
#include "TGeoCache.h"
const Int_t kN3 = 3*sizeof(Double_t);
ClassImp(TGeoNodeCache)
TGeoNodeCache::TGeoNodeCache()
{
fGeoCacheMaxDaughters = 128;
fGeoCacheMaxSize = 1000000;
fGeoCacheStackSize = 1000;
fGeoCacheDefaultLevel = 4;
fGeoCacheMaxLevels = 30;
fGeoCacheObjArrayInd = 0xFF;
fGeoCacheUsageRatio = 0.01;
fSize = 0;
fNused = 0;
fLevel = 0;
fStackLevel = 0;
fStack = 0;
fDefaultLevel= 0;
fCache = 0;
fPath = "";
fTopNode = 0;
fCurrentNode = 0;
fCurrentCache = 0;
fCurrentIndex = 0;
fCurrentID = 0;
fBranch = 0;
fMatrices = 0;
fGlobalMatrix= 0;
fMatrixPool = 0;
fNodeIdArray = 0;
fIndex = 0;
}
TGeoNodeCache::TGeoNodeCache(Bool_t nodeid)
{
fGeoCacheMaxDaughters = 128;
fGeoCacheMaxSize = 1000000;
fGeoCacheStackSize = 1000;
fGeoCacheDefaultLevel = 4;
fGeoCacheMaxLevels = 30;
fGeoCacheObjArrayInd = 0xFF;
fGeoCacheUsageRatio = 0.01;
fSize = 0;
fNused = 0;
fLevel = 0;
fStackLevel = 0;
fStack = 0;
fDefaultLevel= 0;
fCache = 0;
fPath = "";
fTopNode = 0;
fCurrentNode = 0;
fCurrentCache = 0;
fCurrentIndex = 0;
fCurrentID = 0;
fBranch = 0;
fMatrices = 0;
fGlobalMatrix= 0;
fMatrixPool = 0;
fNodeIdArray = 0;
fIndex = 0;
if (nodeid) BuildIdArray();
}
TGeoNodeCache::TGeoNodeCache(Int_t size, Bool_t nodeid)
{
fGeoCacheMaxDaughters = 128;
fGeoCacheMaxSize = 1000000;
fGeoCacheStackSize = 1000;
fGeoCacheDefaultLevel = 4;
fGeoCacheMaxLevels = size;
fGeoCacheObjArrayInd = 0xFF;
fGeoCacheUsageRatio = 0.01;
gGeoManager->SetCache(this);
fDefaultLevel = fGeoCacheDefaultLevel;
fSize = 0;
fNused = 0;
fLevel = 0;
fStackLevel = 0;
fCache = new TGeoNodeArray *[256];
memset(fCache, 0, 0xFF*sizeof(TGeoNodeArray*));
for (Int_t ic=0; ic<fGeoCacheMaxDaughters+1; ic++) {
fCache[ic] = new TGeoNodeArray(ic);
fSize += fCache[ic]->GetSize();
}
fCache[fGeoCacheObjArrayInd] = new TGeoNodeObjArray(0);
fSize += fCache[fGeoCacheObjArrayInd]->GetSize();
fPath = "";
fPath.Resize(400);
fCurrentCache = gGeoManager->GetTopNode()->GetNdaughters();
if (fCurrentCache>fGeoCacheMaxDaughters)
fCurrentCache = fGeoCacheObjArrayInd;
fBranch = new Int_t[fGeoCacheMaxLevels];
memset(fBranch, 0, fGeoCacheMaxLevels*sizeof(Int_t));
memset(fIdBranch, 0, fGeoCacheMaxLevels*sizeof(Int_t));
fMatrices = new Int_t[fGeoCacheMaxLevels];
memset(fMatrices, 0, fGeoCacheMaxLevels*sizeof(Int_t));
fGlobalMatrix = new TGeoHMatrix("current_global");
fTopNode = AddNode(gGeoManager->GetTopNode());
fCurrentNode = fTopNode;
fBranch[0] = fTopNode;
fCache[fCurrentCache]->SetPersistency();
fStack = new TObjArray(fGeoCacheStackSize);
for (Int_t ist=0; ist<fGeoCacheStackSize; ist++)
fStack->Add(new TGeoCacheState(fGeoCacheMaxLevels));
printf("### nodes stored in cache %i ###\n", fSize);
fMatrixPool = new TGeoMatrixCache(0);
fCurrentID = 0;
fNodeIdArray = 0;
fIndex = 0;
if (nodeid) BuildIdArray();
else printf("--- node ID tracking disabled\n");
CdTop();
}
TGeoNodeCache::TGeoNodeCache(const TGeoNodeCache& gnc) :
fGeoCacheUsageRatio(gnc.fGeoCacheUsageRatio),
fGeoCacheMaxDaughters(gnc.fGeoCacheMaxDaughters),
fGeoCacheMaxSize(gnc.fGeoCacheMaxSize),
fGeoCacheDefaultLevel(gnc.fGeoCacheDefaultLevel),
fGeoCacheMaxLevels(gnc.fGeoCacheMaxLevels),
fGeoCacheObjArrayInd(gnc.fGeoCacheObjArrayInd),
fGeoCacheStackSize(gnc.fGeoCacheStackSize),
fLevel(gnc.fLevel),
fCurrentID(gnc.fCurrentID),
fPath(gnc.fPath),
fStack(gnc.fStack),
fNodeIdArray(gnc.fNodeIdArray),
fIndex(gnc.fIndex),
fSize(gnc.fSize),
fNused(gnc.fNused),
fDefaultLevel(gnc.fDefaultLevel),
fTopNode(gnc.fTopNode),
fCount(gnc.fCount),
fCountLimit(gnc.fCountLimit),
fCurrentNode(gnc.fCurrentNode),
fCurrentCache(gnc.fCurrentCache),
fCurrentIndex(gnc.fCurrentIndex),
fBranch(gnc.fBranch),
fMatrices(gnc.fMatrices),
fStackLevel(gnc.fStackLevel),
fGlobalMatrix(gnc.fGlobalMatrix),
fCache(gnc.fCache),
fMatrixPool(gnc.fMatrixPool)
{
for(Int_t i=0; i<30; i++) fIdBranch[i]=gnc.fIdBranch[i];
}
TGeoNodeCache& TGeoNodeCache::operator=(const TGeoNodeCache& gnc)
{
if(this!=&gnc) {
fGeoCacheUsageRatio=gnc.fGeoCacheUsageRatio;
fGeoCacheMaxDaughters=gnc.fGeoCacheMaxDaughters;
fGeoCacheMaxSize=gnc.fGeoCacheMaxSize;
fGeoCacheDefaultLevel=gnc.fGeoCacheDefaultLevel;
fGeoCacheMaxLevels=gnc.fGeoCacheMaxLevels;
fGeoCacheObjArrayInd=gnc.fGeoCacheObjArrayInd;
fGeoCacheStackSize=gnc.fGeoCacheStackSize;
fLevel=gnc.fLevel;
fCurrentID=gnc.fCurrentID;
fPath=gnc.fPath;
fStack=gnc.fStack;
fNodeIdArray=gnc.fNodeIdArray;
fIndex=gnc.fIndex;
fSize=gnc.fSize;
fNused=gnc.fNused;
fDefaultLevel=gnc.fDefaultLevel;
fTopNode=gnc.fTopNode;
fCount=gnc.fCount;
fCountLimit=gnc.fCountLimit;
fCurrentNode=gnc.fCurrentNode;
fCurrentCache=gnc.fCurrentCache;
fCurrentIndex=gnc.fCurrentIndex;
fBranch=gnc.fBranch;
fMatrices=gnc.fMatrices;
fStackLevel=gnc.fStackLevel;
fGlobalMatrix=gnc.fGlobalMatrix;
fCache=gnc.fCache;
fMatrixPool=gnc.fMatrixPool;
for(Int_t i=0; i<30; i++) fIdBranch[i]=gnc.fIdBranch[i];
}
return *this;
}
TGeoNodeCache::~TGeoNodeCache()
{
if (fCache) {
DeleteCaches();
delete [] fBranch;
delete [] fMatrices;
delete fGlobalMatrix;
delete fMatrixPool;
}
if (fStack) {
fStack->Delete();
delete fStack;
}
if (fNodeIdArray) delete [] fNodeIdArray;
}
void TGeoNodeCache::BuildIdArray()
{
Int_t nnodes = gGeoManager->GetNNodes();
if (fNodeIdArray) delete [] fNodeIdArray;
printf("--- node ID tracking enabled, size=%d Bytes\n", (Int_t)((2*nnodes+1)*sizeof(Int_t)));
fNodeIdArray = new Int_t[2*nnodes+1];
fNodeIdArray[0] = 0;
Int_t ifree = 1;
Int_t nodeid = 0;
gGeoManager->GetTopNode()->FillIdArray(ifree, nodeid, fNodeIdArray);
fIdBranch[0] = 0;
}
Int_t TGeoNodeCache::GetCurrentNodeId() const
{
if (fNodeIdArray) return fNodeIdArray[fIndex];
return GetNodeId();
}
void TGeoNodeCache::Compact()
{
Int_t old_size, new_size;
for (Int_t ic=0; ic<fGeoCacheMaxDaughters+1; ic++) {
old_size = fCache[ic]->GetSize();
fCache[ic]->Compact();
new_size = fCache[ic]->GetSize();
fSize -= (old_size-new_size);
}
}
void TGeoNodeCache::DeleteCaches()
{
if (!fCache) return;
for (Int_t ic=0; ic<fGeoCacheMaxDaughters+1; ic++) {
fCache[ic]->DeleteArray();
delete fCache[ic];
}
delete fCache[fGeoCacheObjArrayInd];
delete [] fCache;
}
Int_t TGeoNodeCache::AddNode(TGeoNode *node)
{
Int_t ic = node->GetNdaughters();
if (ic > fGeoCacheMaxDaughters) ic = fGeoCacheObjArrayInd;
return fCache[ic]->AddNode(node);
}
void TGeoNodeCache::CdNode(Int_t nodeid) {
if (!fNodeIdArray) {
printf("WARNING:CdNode() disabled - too many nodes\n");
return;
}
Int_t *arr = fNodeIdArray;
if (nodeid == arr[fIndex]) return;
while (fLevel>0) {
gGeoManager->CdUp();
if (nodeid == arr[fIndex]) return;
}
gGeoManager->CdTop();
Int_t currentID = 0;
Int_t nd = GetNode()->GetNdaughters();
Int_t nabove, nbelow, middle;
while (nodeid!=currentID && nd) {
nabove = nd+1;
nbelow = 0;
while (nabove-nbelow > 1) {
middle = (nabove+nbelow)>>1;
currentID = arr[arr[fIndex+middle]];
if (nodeid == currentID) {
gGeoManager->CdDown(middle-1);
return;
}
if (nodeid < currentID) nabove = middle;
else nbelow = middle;
}
gGeoManager->CdDown(nbelow-1);
currentID = arr[fIndex];
nd = GetNode()->GetNdaughters();
}
}
Bool_t TGeoNodeCache::CdDown(Int_t index, Bool_t make)
{
fCache[fCurrentCache]->cd(fCurrentIndex);
Int_t nind_d = fCache[fCurrentCache]->GetDaughter(index);
Bool_t persistent = kFALSE;
if (!nind_d) {
if (!make) return kFALSE;
TGeoNode *node = GetNode()->GetDaughter(index);
nind_d = fCache[fCurrentCache]->AddDaughter(node, index);
fNused++;
if (fLevel < fGeoCacheDefaultLevel) persistent=kTRUE;
}
fBranch[++fLevel] = nind_d;
if (fNodeIdArray) {
fIndex = fNodeIdArray[fIndex+index+1];
fIdBranch[fLevel] = fIndex;
}
fCurrentNode = nind_d;
fCurrentCache = CacheId(nind_d);
fCurrentIndex = Index(nind_d);
fCache[fCurrentCache]->cd(fCurrentIndex);
if (!make) return kTRUE;
if (persistent) fCache[fCurrentCache]->SetPersistency();
fMatrices[fLevel] = fCache[fCurrentCache]->GetMatrixInd();
if (fMatrices[fLevel]) {
fMatrixPool->cd(fMatrices[fLevel]);
return kTRUE;
}
TGeoMatrix *local = GetNode()->GetMatrix();
if (local->IsIdentity()) {
fMatrices[fLevel] = fMatrices[fLevel-1];
fCache[fCurrentCache]->SetMatrix(fMatrices[fLevel]);
return kTRUE;
}
fMatrixPool->GetMatrix(fGlobalMatrix);
fGlobalMatrix->Multiply(local);
fMatrices[fLevel] = fCache[fCurrentCache]->AddMatrix(fGlobalMatrix);
return kTRUE;
}
void TGeoNodeCache::CdUp()
{
if (!fLevel) return;
fLevel--;
if (fNodeIdArray) fIndex = fIdBranch[fLevel];
fCurrentNode = fBranch[fLevel];
fCurrentCache = CacheId(fCurrentNode);
fCurrentIndex = Index(fCurrentNode);
fCache[fCurrentCache]->cd(fCurrentIndex);
fMatrixPool->cd(fMatrices[fLevel]);
}
void TGeoNodeCache::CleanCache()
{
printf("Cleaning cache...\n");
fCountLimit = Int_t(fGeoCacheUsageRatio*(Double_t)fCount);
Int_t level = fLevel;
Int_t *branch = new Int_t[fGeoCacheMaxLevels];
Bool_t *flags = new Bool_t[fGeoCacheMaxLevels];
memcpy(&branch[0], fBranch, fGeoCacheMaxLevels*sizeof(Int_t));
Int_t i;
for (i=0; i<level+1; i++) {
Int_t ic = CacheId(branch[i]);
Int_t index = Index(branch[i]);
fCache[ic]->cd(index);
flags[i] = fCache[ic]->IsPersistent();
fCache[ic]->SetPersistency();
}
CdTop();
DumpNodes();
memcpy(fBranch, &branch[0], fGeoCacheMaxLevels*sizeof(Int_t));
for (i=0; i<level+1; i++) {
Int_t ic = CacheId(branch[i]);
Int_t index = Index(branch[i]);
fCache[ic]->cd(index);
fCache[ic]->SetPersistency(flags[i]);
}
fLevel = level;
fCurrentNode = fBranch[fLevel];
fCurrentCache = CacheId(fCurrentNode);
fCurrentIndex = Index(fCurrentNode);
Status();
delete [] branch;
delete [] flags;
}
Bool_t TGeoNodeCache::DumpNodes()
{
Int_t ndaughters = fCache[fCurrentCache]->GetNdaughters();
fCache[fCurrentCache]->cd(fCurrentIndex);
if (!SetPersistency()) return kTRUE;
for (Int_t id=0; id<ndaughters; id++) {
if (!CdDown(id, kFALSE)) continue;
if (DumpNodes()) {
CdUp();
ClearDaughter(id);
} else {
CdUp();
}
}
return kFALSE;
}
void TGeoNodeCache::ClearNode(Int_t nindex)
{
Int_t ic = CacheId(nindex);
Int_t index = Index(nindex);
fCache[ic]->cd(index);
fNused--;
fCount-=GetUsageCount();
fCache[ic]->ClearNode();
}
TGeoNode *TGeoNodeCache::GetMother(Int_t up) const
{
if (!fLevel || (up>fLevel)) return 0;
Int_t inode = fBranch[fLevel-up];
Int_t id = CacheId(inode);
fCache[id]->cd(Index(inode));
TGeoNode *mother = fCache[id]->GetNode();
if (fCurrentCache == id) fCache[fCurrentCache]->cd(fCurrentIndex);
return mother;
}
Int_t TGeoNodeCache::GetNodeId() const
{
return fBranch[fLevel];
}
const char *TGeoNodeCache::GetPath()
{
fPath = "";
for (Int_t level=0;level<fLevel+1; level++) {
Int_t nindex = fBranch[level];
Int_t ic = CacheId(nindex);
Int_t index = Index(nindex);
fCache[ic]->cd(index);
fPath += "/";
fPath += fCache[ic]->GetNode()->GetName();
}
return fPath.Data();
}
void TGeoNodeCache::PrintNode() const
{
TGeoNode *node = GetNode();
printf("***********************************************\n");
printf(" Node : %s\n", node->GetName());
Int_t mat = fMatrices[fLevel];
printf(" Global matrix : %i\n", mat);
Bool_t persistency = fCache[fCurrentCache]->IsPersistent();
UInt_t count = fCache[fCurrentCache]->GetUsageCount();
printf(" persistency=%i usage=%i\n", (Int_t)persistency, count);
Int_t nd = fCache[fCurrentCache]->GetNdaughters();
printf(" daughters : %i from %i\n", nd, node->GetNdaughters());
for (Int_t i=0; i<nd; i++) {
Int_t nindex_d = fCache[fCurrentCache]->GetDaughter(i);
if (!nindex_d) continue;
Int_t ic = CacheId(nindex_d);
Int_t index = Index(nindex_d);
fCache[ic]->cd(index);
TGeoNode *dght = fCache[ic]->GetNode();
if (dght) printf(" %i : %s\n", i, dght->GetName());
}
}
Int_t TGeoNodeCache::PushState(Bool_t ovlp, Int_t startlevel, Int_t nmany, Double_t *point)
{
if (fStackLevel>=fGeoCacheStackSize) {
printf("ERROR TGeoNodeCach::PushSate() : stack of states full\n");
return 0;
}
((TGeoCacheState*)fStack->At(fStackLevel))->SetState(fLevel,startlevel,nmany,ovlp,point);
return ++fStackLevel;
}
void TGeoNodeCache::Refresh()
{
if (fLevel<0) {
gGeoManager->SetOutside();
fLevel = 0;
}
fCurrentNode=fBranch[fLevel];
fCurrentCache=CacheId(fCurrentNode);
fCurrentIndex=Index(fCurrentNode);
fCache[fCurrentCache]->cd(fCurrentIndex);
fMatrixPool->cd(fMatrices[fLevel]);
}
Bool_t TGeoNodeCache::PopState(Int_t &nmany, Double_t *point)
{
if (!fStackLevel) return 0;
Bool_t ovlp = ((TGeoCacheState*)fStack->At(--fStackLevel))->GetState(fLevel,nmany,point);
Refresh();
return ovlp;
}
Bool_t TGeoNodeCache::PopState(Int_t &nmany, Int_t level, Double_t *point)
{
if (level<=0) return 0;
((TGeoCacheState*)fStack->At(level-1))->GetState(fLevel,nmany,point);
Refresh();
return level;
}
Bool_t TGeoNodeCache::SetPersistency()
{
if (fCache[fCurrentCache]->IsPersistent()) return kTRUE;
Int_t usage = GetUsageCount();
if (usage>fCountLimit) {
fCache[fCurrentCache]->SetPersistency();
return kTRUE;
}
return kFALSE;
}
void TGeoNodeCache::Status() const
{
printf("Cache status : total %i used %i free %i nodes\n",
fSize, fNused, fSize-fNused);
}
ClassImp(TGeoCacheDummy)
TGeoCacheDummy::TGeoCacheDummy()
{
fTop = 0;
fNode = 0;
fNodeBranch = 0;
fMatrixBranch = 0;
fMPB = 0;
fMatrix = 0;
}
TGeoCacheDummy::TGeoCacheDummy(TGeoNode *top, Bool_t nodeid, Int_t capacity)
:TGeoNodeCache(nodeid)
{
fGeoCacheMaxLevels = capacity;
fTop = top;
fNode = top;
fNodeBranch = new TGeoNode *[fGeoCacheMaxLevels];
fNodeBranch[0] = top;
fMatrixBranch = new TGeoHMatrix *[fGeoCacheMaxLevels];
fMPB = new TGeoHMatrix *[fGeoCacheMaxLevels];
for (Int_t i=0; i<fGeoCacheMaxLevels; i++) {
fMPB[i] = new TGeoHMatrix("global");
fMatrixBranch[i] = 0;
}
fMatrix = fMatrixBranch[0] = fMPB[0];
fStack = new TObjArray(fGeoCacheStackSize);
for (Int_t ist=0; ist<fGeoCacheStackSize; ist++)
fStack->Add(new TGeoCacheStateDummy(fGeoCacheMaxLevels));
fMatrixPool = 0;
}
TGeoCacheDummy::TGeoCacheDummy(const TGeoCacheDummy& gcd) :
TGeoNodeCache(gcd),
fTop(gcd.fTop),
fNode(gcd.fNode),
fMatrix(gcd.fMatrix),
fMatrixBranch(gcd.fMatrixBranch),
fMPB(gcd.fMPB),
fNodeBranch(gcd.fNodeBranch)
{
}
TGeoCacheDummy& TGeoCacheDummy::operator=(const TGeoCacheDummy& gcd)
{
if(this!=&gcd) {
TGeoNodeCache::operator=(gcd);
fTop=gcd.fTop;
fNode=gcd.fNode;
fMatrix=gcd.fMatrix;
fMatrixBranch=gcd.fMatrixBranch;
fMPB=gcd.fMPB;
fNodeBranch=gcd.fNodeBranch;
}
return *this;
}
TGeoCacheDummy::~TGeoCacheDummy()
{
if (fNodeBranch) delete [] fNodeBranch;
if (fMPB) {
for (Int_t i=0; i<fGeoCacheMaxLevels; i++)
delete fMPB[i];
delete [] fMPB;
}
if (fMatrixBranch) delete [] fMatrixBranch;
}
Bool_t TGeoCacheDummy::CdDown(Int_t index, Bool_t )
{
TGeoNode *newnode = fNode->GetDaughter(index);
if (!newnode) return kFALSE;
fLevel++;
if (fNodeIdArray) {
fIndex = fNodeIdArray[fIndex+index+1];
fIdBranch[fLevel] = fIndex;
}
fNode = newnode;
fNodeBranch[fLevel] = fNode;
TGeoMatrix *local = newnode->GetMatrix();
TGeoHMatrix *newmat = fMPB[fLevel];
if (!local->IsIdentity()) {
*newmat = fMatrix;
newmat->Multiply(local);
fMatrix = newmat;
}
fMatrixBranch[fLevel] = fMatrix;
return kTRUE;
}
void TGeoCacheDummy::CdUp()
{
if (!fLevel) return;
fLevel--;
if (fNodeIdArray) fIndex = fIdBranch[fLevel];
fNode = fNodeBranch[fLevel];
fMatrix = fMatrixBranch[fLevel];
}
Int_t TGeoCacheDummy::GetNodeId() const
{
Long_t id=0;
for (Int_t level=0;level<fLevel+1; level++)
id += (Long_t)fNodeBranch[level];
return (Int_t)id;
}
void TGeoCacheDummy::GetBranchNames(Int_t *names) const
{
const char *name;
for (Int_t i=0; i<fLevel+1; i++) {
name = fNodeBranch[i]->GetVolume()->GetName();
memcpy(&names[i], name, sizeof(Int_t));
}
}
void TGeoCacheDummy::GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
{
for (Int_t i=0; i<fLevel+1; i++) {
copyNumbers[i] = fNodeBranch[i]->GetNumber();
volumeNumbers[i] = fNodeBranch[i]->GetVolume()->GetNumber();
}
}
void TGeoCacheDummy::GetBranchOnlys(Int_t *isonly) const
{
Bool_t ismany = kFALSE;
for (Int_t i=0; i<fLevel+1; i++) {
if (!fNodeBranch[i]->IsOffset()) ismany=fNodeBranch[i]->IsOverlapping();
isonly[i] = (ismany)?0:1;
}
}
const char *TGeoCacheDummy::GetPath()
{
fPath = "";
for (Int_t level=0;level<fLevel+1; level++) {
fPath += "/";
fPath += fNodeBranch[level]->GetName();
}
return fPath.Data();
}
void TGeoCacheDummy::LocalToMaster(const Double_t *local, Double_t *master) const
{
fMatrix->LocalToMaster(local, master);
}
void TGeoCacheDummy::LocalToMasterVect(const Double_t *local, Double_t *master) const
{
fMatrix->LocalToMasterVect(local, master);
}
void TGeoCacheDummy::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
fMatrix->LocalToMasterBomb(local, master);
}
void TGeoCacheDummy::MasterToLocal(const Double_t *master, Double_t *local) const
{
if (fMatrix->IsIdentity()) {
memcpy(local, master, kN3);
return;
}
const Double_t *tr = fMatrix->GetTranslation();
const Double_t *rot = fMatrix->GetRotationMatrix();
Double_t mt0 = master[0]-tr[0];
Double_t mt1 = master[1]-tr[1];
Double_t mt2 = master[2]-tr[2];
local[0] = mt0*rot[0] + mt1*rot[3] + mt2*rot[6];
local[1] = mt0*rot[1] + mt1*rot[4] + mt2*rot[7];
local[2] = mt0*rot[2] + mt1*rot[5] + mt2*rot[8];
}
void TGeoCacheDummy::MasterToLocalVect(const Double_t *master, Double_t *local) const
{
if (fMatrix->IsIdentity()) {
memcpy(local, master, kN3);
return;
}
const Double_t *rot = fMatrix->GetRotationMatrix();
for (Int_t i=0; i<3; i++) {
local[i] = master[0]*rot[i]
+ master[1]*rot[i+3]
+ master[2]*rot[i+6];
}
}
void TGeoCacheDummy::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
fMatrix->MasterToLocalBomb(master, local);
}
const Int_t TGeoNodeArray::fgGeoArrayMaxSize = 1000000;
const Int_t TGeoNodeArray::fgGeoArrayInitSize = 1000;
const Int_t TGeoNodeArray::fgGeoReleasedSpace = 1000;
ClassImp(TGeoNodeArray)
TGeoNodeArray::TGeoNodeArray()
{
fNdaughters = 0;
fSize = 0;
fNodeSize = 0;
fFirstFree = 0;
fCurrent = 0;
fNused = 0;
fOffset = 0;
fBitsArray = 0;
fArray = 0;
}
TGeoNodeArray::TGeoNodeArray(Int_t ndaughters, Int_t size)
{
if ((ndaughters<0) || (ndaughters>254)) return;
fNdaughters = ndaughters;
fSize = size;
if ((size<fgGeoArrayInitSize) || (size>fgGeoArrayMaxSize))
fSize = fgGeoArrayInitSize;
fNodeSize = 3+fNdaughters;
fFirstFree = 0;
fCurrent = 0;
fNused = 0;
fOffset = 0;
fBitsArray = new TBits(fSize);
fArray = new Int_t[fSize*fNodeSize];
memset(fArray, 0, fSize*fNodeSize*sizeof(Int_t));
if (!fNdaughters) {
fFirstFree = fCurrent = 1;
fBitsArray->SetBitNumber(0);
}
}
TGeoNodeArray::TGeoNodeArray(const TGeoNodeArray& gna) :
TObject(gna),
fNodeSize(gna.fNodeSize),
fNdaughters(gna.fNdaughters),
fOffset(gna.fOffset),
fSize(gna.fSize),
fFirstFree(gna.fFirstFree),
fCurrent(gna.fCurrent),
fNused(gna.fNused),
fBitsArray(gna.fBitsArray),
fArray(gna.fArray)
{
}
TGeoNodeArray& TGeoNodeArray::operator=(const TGeoNodeArray& gna)
{
if(this!=&gna) {
TObject::operator=(gna);
fNodeSize=gna.fNodeSize;
fNdaughters=gna.fNdaughters;
fOffset=gna.fOffset;
fSize=gna.fSize;
fFirstFree=gna.fFirstFree;
fCurrent=gna.fCurrent;
fNused=gna.fNused;
fBitsArray=gna.fBitsArray;
fArray=gna.fArray;
}
return *this;
}
TGeoNodeArray::~TGeoNodeArray()
{
}
Int_t TGeoNodeArray::AddDaughter(TGeoNode *node, Int_t i)
{
return (fOffset[3+i]=gGeoManager->GetCache()->AddNode(node));
}
Int_t TGeoNodeArray::AddMatrix(TGeoMatrix *global)
{
return (fOffset[1]=gGeoManager->GetCache()->GetMatrixPool()->AddMatrix(global));
}
void TGeoNodeArray::Compact()
{
fBitsArray->Compact();
Int_t new_size = fBitsArray->GetNbits();
Int_t *old_array = fArray;
fArray = new Int_t[new_size*fNodeSize];
memcpy(fArray, old_array, new_size*fNodeSize*sizeof(Int_t));
delete [] old_array;
fSize = new_size;
}
void TGeoNodeArray::DeleteArray()
{
if (fArray) delete [] fArray;
fArray = 0;
if (fBitsArray) delete fBitsArray;
fBitsArray = 0;
}
Int_t TGeoNodeArray::AddNode(TGeoNode *node)
{
Int_t index = fFirstFree;
Int_t current = fCurrent;
cd(index);
memset(fOffset, 0, fNodeSize*sizeof(Int_t));
fOffset[0] = (ULong_t)node - (ULong_t)gSystem;
fBitsArray->SetBitNumber(fFirstFree);
fFirstFree = fBitsArray->FirstNullBit(fFirstFree);
fNused++;
if (fFirstFree >= fSize-1) IncreaseArray();
UChar_t *cache = (UChar_t*)&index;
cache[3] = (UChar_t)fNdaughters;
cd(current);
return index;
}
void TGeoNodeArray::ClearDaughter(Int_t ind)
{
Int_t nindex_d = GetDaughter(ind);
if (!nindex_d) return;
fOffset[3+ind] = 0;
gGeoManager->GetCache()->ClearNode(nindex_d);
}
void TGeoNodeArray::ClearMatrix()
{
Int_t ind_mat = fOffset[1];
if (ind_mat && !(GetNode()->GetMatrix()->IsIdentity()))
gGeoManager->GetCache()->GetMatrixPool()->ClearMatrix(ind_mat);
}
void TGeoNodeArray::ClearNode()
{
Int_t inode = fCurrent;
for (Int_t ind=0; ind<fNdaughters; ind++) ClearDaughter(ind);
cd(inode);
ClearMatrix();
if (fCurrent<fFirstFree) fFirstFree = fCurrent;
fBitsArray->SetBitNumber(fCurrent, kFALSE);
fNused--;
memset(fOffset, 0, fNodeSize*sizeof(Int_t));
}
Bool_t TGeoNodeArray::HasDaughters() const
{
for (Int_t ind=0; ind<fNdaughters; ind++) {
if (fOffset[3+ind]) return kTRUE;
}
return kFALSE;
}
void TGeoNodeArray::IncreaseArray()
{
Int_t new_size = 2*fSize;
Int_t free_space = gGeoManager->GetCache()->GetFreeSpace();
if (free_space<10) {
gGeoManager->GetCache()->CleanCache();
return;
}
if (free_space<fSize) new_size = fSize+free_space;
fBitsArray->SetBitNumber(new_size-1, kFALSE);
Int_t *new_array = new Int_t[new_size*fNodeSize];
memset(new_array, 0, new_size*fNodeSize*sizeof(Int_t));
memcpy(new_array, fArray, fSize*fNodeSize*sizeof(Int_t));
delete [] fArray;
fArray = new_array;
gGeoManager->GetCache()->IncreasePool(new_size-fSize);
fSize = new_size;
}
Bool_t TGeoNodeArray::IsPersistent() const
{
return ((fOffset[2] & 0x80000000)==0)?kFALSE:kTRUE;
}
void TGeoNodeArray::SetPersistency(Bool_t flag)
{
if (flag) fOffset[2] |= 0x80000000;
else fOffset[2] &= 0x7FFFFFFF;
}
ClassImp(TGeoNodeObjArray)
TGeoNodeObjArray::TGeoNodeObjArray()
{
fObjArray = 0;
fCurrent = 0;
fIndex = 0;
}
TGeoNodeObjArray::TGeoNodeObjArray(Int_t size)
{
fSize = size;
fIndex = 0;
if (size<TGeoNodeArray::fgGeoArrayInitSize)
fSize = TGeoNodeArray::fgGeoArrayInitSize;
fObjArray = new TObjArray(fSize);
for (Int_t i=0; i<fSize; i++) fObjArray->AddAt(new TGeoNodePos(), i);
fBitsArray = new TBits(fSize);
fCurrent = 0;
}
TGeoNodeObjArray::TGeoNodeObjArray(const TGeoNodeObjArray& noa) :
TGeoNodeArray(noa),
fIndex(noa.fIndex),
fObjArray(noa.fObjArray),
fCurrent(noa.fCurrent)
{
}
TGeoNodeObjArray& TGeoNodeObjArray::operator=(const TGeoNodeObjArray& noa)
{
if(this!=&noa) {
TGeoNodeArray::operator=(noa);
fIndex=noa.fIndex;
fObjArray=noa.fObjArray;
fCurrent=noa.fCurrent;
}
return *this;
}
TGeoNodeObjArray::~TGeoNodeObjArray()
{
if (!fObjArray) return;
fObjArray->Delete();
delete fObjArray;
}
Int_t TGeoNodeObjArray::AddDaughter(TGeoNode *node, Int_t i)
{
return fCurrent->AddDaughter(i, gGeoManager->GetCache()->AddNode(node));
}
Int_t TGeoNodeObjArray::AddNode(TGeoNode *node)
{
Int_t index = fFirstFree;
Int_t oldindex = fIndex;
cd(index);
fCurrent->Map(node);
fBitsArray->SetBitNumber(fFirstFree);
fFirstFree = fBitsArray->FirstNullBit(fFirstFree);
fNused++;
if (fFirstFree >= fSize-1) IncreaseArray();
UChar_t *cache = (UChar_t*)&index;
cache[3] = 0xFF;
cd(oldindex);
return index;
}
Int_t TGeoNodeObjArray::AddMatrix(TGeoMatrix *global)
{
return fCurrent->AddMatrix(global);
}
void TGeoNodeObjArray::cd(Int_t inode)
{
fCurrent = (TGeoNodePos*)fObjArray->At(inode);
fIndex = inode;
}
void TGeoNodeObjArray::ClearDaughter(Int_t ind)
{
Int_t nindex = fCurrent->GetDaughter(ind);
if (!nindex) return;
fCurrent->ClearDaughter(ind);
gGeoManager->GetCache()->ClearNode(nindex);
}
void TGeoNodeObjArray::ClearMatrix()
{
Int_t ind_mat = fCurrent->GetMatrixInd();
if (ind_mat && !fCurrent->GetNode()->GetMatrix()->IsIdentity())
gGeoManager->GetCache()->GetMatrixPool()->ClearMatrix(ind_mat);
}
void TGeoNodeObjArray::ClearNode()
{
Int_t inode = fIndex;
Int_t nd = GetNdaughters();
for (Int_t ind=0; ind<nd; ind++) ClearDaughter(ind);
cd(inode);
ClearMatrix();
if (fIndex<fFirstFree) fFirstFree = fIndex;
fBitsArray->SetBitNumber(fIndex, kFALSE);
fNused--;
}
void TGeoNodeObjArray::IncreaseArray()
{
Int_t new_size = 2*fSize;
Int_t free_space = gGeoManager->GetCache()->GetFreeSpace();
if (free_space<10) {
gGeoManager->GetCache()->CleanCache();
return;
}
if (free_space<fSize) new_size = fSize+free_space;
fBitsArray->SetBitNumber(new_size-1, kFALSE);
fObjArray->Expand(new_size);
for (Int_t i=fSize; i<new_size; i++) fObjArray->AddAt(new TGeoNodePos(), i);
gGeoManager->GetCache()->IncreasePool(new_size-fSize);
fSize = new_size;
}
const Int_t TGeoNodePos::fgPersistentNodeMask = 0x80000000;
const UChar_t TGeoNodePos::fgPersistentMatrixMask = 64;
const UInt_t TGeoNodePos::fgNoMatrix = 1000000000;
ClassImp(TGeoNodePos)
TGeoNodePos::TGeoNodePos()
{
fNdaughters = 0;
fDaughters = 0;
fMatrix = 0;
fCount = 0;
fNode = 0;
}
TGeoNodePos::TGeoNodePos(const TGeoNodePos& gnp) :
TObject(gnp),
fNdaughters(gnp.fNdaughters),
fMatrix(gnp.fMatrix),
fCount(gnp.fCount),
fDaughters(gnp.fDaughters),
fNode(gnp.fNode)
{
}
TGeoNodePos& TGeoNodePos::operator=(const TGeoNodePos& gnp)
{
if(this!=&gnp) {
TObject::operator=(gnp);
fNdaughters=gnp.fNdaughters;
fMatrix=gnp.fMatrix;
fCount=gnp.fCount;
fDaughters=gnp.fDaughters;
fNode=gnp.fNode;
}
return *this;
}
TGeoNodePos::TGeoNodePos(Int_t ndaughters)
{
fNdaughters = ndaughters;
if (ndaughters < 0xFF) return;
if (ndaughters) {
fDaughters = new Int_t[ndaughters];
memset(fDaughters, 0, ndaughters*sizeof(Int_t));
} else {
fDaughters = 0;
}
fMatrix = 0;
fCount = 0;
fNode = 0;
}
TGeoNodePos::~TGeoNodePos()
{
if (fDaughters) delete [] fDaughters;
}
Int_t TGeoNodePos::AddMatrix(TGeoMatrix *global)
{
return (fMatrix=gGeoManager->GetCache()->GetMatrixPool()->AddMatrix(global));
}
void TGeoNodePos::ClearMatrix()
{
if (fMatrix && !fNode->GetMatrix()->IsIdentity()) {
gGeoManager->GetCache()->GetMatrixPool()->ClearMatrix(fMatrix);
fMatrix = 0;
}
}
Int_t TGeoNodePos::GetDaughter(Int_t ind) const
{
if (fDaughters) return fDaughters[ind];
return 0;
}
Bool_t TGeoNodePos::HasDaughters() const
{
for (Int_t i=0; i<fNdaughters; i++) {
if (fDaughters[i]!=0) return kTRUE;
}
return kFALSE;
}
void TGeoNodePos::Map(TGeoNode *node)
{
fNdaughters = node->GetNdaughters();
if (fDaughters) delete [] fDaughters;
fDaughters = new Int_t[fNdaughters];
memset(fDaughters, 0, fNdaughters*sizeof(Int_t));
fMatrix = 0;
fCount = 0;
fNode = node;
}
void TGeoNodePos::SetPersistency(Bool_t flag)
{
if (flag) fCount |= fgPersistentNodeMask;
else fCount &= !fgPersistentNodeMask;
}
ClassImp(TGeoMatrixCache)
TGeoMatrixCache::TGeoMatrixCache()
{
for (Int_t i=0; i<7; i++) {
fSize[i] = 0;
fCache[i] = 0;
fFree[i] = 0;
fBitsArray[i] = 0;
}
fGeoMinCacheSize = 1000;
fMatrix = 0;
fHandler = 0;
fCacheId = 0;
fLength = 0;
fHandlers = 0;
}
TGeoMatrixCache::TGeoMatrixCache(Int_t size)
{
fGeoMinCacheSize = 1000;
Int_t length;
for (Int_t i=0; i<7; i++) {
if (size < fGeoMinCacheSize) {
fSize[i] = fGeoMinCacheSize;
} else {
fSize[i] = size;
}
length = 3*(i-1);
if (length == 0) length=2;
if (length < 0) length=1;
fCache[i] = new Double_t[fSize[i]*length];
fBitsArray[i] = new TBits(fSize[i]);
fFree[i] = 0;
if (i==0) {
fBitsArray[i]->SetBitNumber(0);
fFree[i] = 1;
}
}
fMatrix = 0;
fHandler = 0;
fCacheId = 0;
fLength = 0;
fHandlers = new TGeoMatHandler *[14];
fHandlers[0] = new TGeoMatHandlerX();
fHandlers[1] = new TGeoMatHandlerY();
fHandlers[2] = new TGeoMatHandlerZ();
fHandlers[3] = new TGeoMatHandlerXY();
fHandlers[4] = new TGeoMatHandlerXZ();
fHandlers[5] = new TGeoMatHandlerYZ();
fHandlers[6] = new TGeoMatHandlerXYZ();
fHandlers[7] = new TGeoMatHandlerRot();
fHandlers[8] = new TGeoMatHandlerRotTr();
fHandlers[9] = new TGeoMatHandlerScl();
fHandlers[10] = new TGeoMatHandlerTrScl();
fHandlers[11] = new TGeoMatHandlerRotScl();
fHandlers[12] = new TGeoMatHandlerRotTrScl();
fHandlers[13] = new TGeoMatHandlerId();
printf("### matrix caches of size %i built ###\n", fSize[0]);
}
TGeoMatrixCache::TGeoMatrixCache(const TGeoMatrixCache& gmc) :
fMatrix(gmc.fMatrix),
fHandler(gmc.fHandler),
fCacheId(gmc.fCacheId),
fLength(gmc.fLength),
fHandlers(gmc.fHandlers),
fGeoMinCacheSize(gmc.fGeoMinCacheSize)
{
for(Int_t i=0; i<7; i++) {
fSize[i]=gmc.fSize[i];
fFree[i]=gmc.fFree[i];
fCache[i]=gmc.fCache[i];
fBitsArray[i]=gmc.fBitsArray[i];
}
}
TGeoMatrixCache& TGeoMatrixCache::operator=(const TGeoMatrixCache& gmc)
{
if(this!=&gmc) {
fMatrix=gmc.fMatrix;
fHandler=gmc.fHandler;
fCacheId=gmc.fCacheId;
fLength=gmc.fLength;
for(Int_t i=0; i<7; i++) {
fSize[i]=gmc.fSize[i];
fFree[i]=gmc.fFree[i];
fCache[i]=gmc.fCache[i];
fBitsArray[i]=gmc.fBitsArray[i];
}
fHandlers=gmc.fHandlers;
fGeoMinCacheSize=gmc.fGeoMinCacheSize;
}
return *this;
}
TGeoMatrixCache::~TGeoMatrixCache()
{
if (fSize[0]) {
for (Int_t i=0; i<7; i++) {
delete fCache[i];
delete fBitsArray[i];
}
for (Int_t j=0; j<14; j++)
delete fHandlers[j];
delete [] fHandlers;
}
}
Int_t TGeoMatrixCache::AddMatrix(TGeoMatrix *matrix)
{
if (matrix->IsIdentity()) {fHandler=13; return (fMatrix=0);}
const Double_t *translation = matrix->GetTranslation();
UChar_t type = 0;
if (matrix->IsRotation()) type |= 8;
if (matrix->IsScale()) type |= 16;
if (matrix->IsTranslation()) {
if (translation[0]!=0) type |= 1;
if (translation[1]!=0) type |= 2;
if (translation[2]!=0) type |= 4;
}
const Int_t cache_id[32] = {
0, 0, 0, 1, 0, 1, 1, 2, 4, 5, 5, 5, 5, 5, 5, 5,
2, 3, 3, 3, 3, 3, 3, 3, 5, 6, 6, 6, 6, 6, 6, 6};
const Int_t cache_len[32] = {
0, 1, 1, 2, 1, 2, 2, 3, 9,12,12,12,12,12,12,12,
3, 6, 6, 6, 6, 6, 6, 6,12,15,15,15,15,15,15,15};
const Int_t handler_id[32] = {
0, 0, 1, 3, 2, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8,
9,10,10,10,10,10,10,10,11,12,12,12,12,12,12,12};
fCacheId = cache_id[type];
fLength = cache_len[type];
fHandler = handler_id[type];
UInt_t current_free = fFree[fCacheId];
Double_t *location = fCache[fCacheId]+fLength*current_free;
TGeoMatHandler *handler = fHandlers[fHandler];
handler->AddMatrix(location, matrix);
fBitsArray[fCacheId]->SetBitNumber(current_free);
fFree[fCacheId] = fBitsArray[fCacheId]->FirstNullBit(current_free);
if (fFree[fCacheId] >= fSize[fCacheId]-1) {
IncreaseCache();
location = fCache[fCacheId]+fLength*current_free;
handler->SetLocation(location);
}
fMatrix = current_free;
UChar_t *type_loc = (UChar_t*)&fMatrix+3;
*type_loc = type;
return fMatrix;
}
void TGeoMatrixCache::cd(Int_t mindex)
{
fMatrix = mindex;
if (!fMatrix) {
fHandler = 13;
return;
}
const Int_t cache_id[32] = {
0, 0, 0, 1, 0, 1, 1, 2, 4, 5, 5, 5, 5, 5, 5, 5,
2, 3, 3, 3, 3, 3, 3, 3, 5, 6, 6, 6, 6, 6, 6, 6};
const Int_t cache_len[32] = {
0, 1, 1, 2, 1, 2, 2, 3, 9,12,12,12,12,12,12,12,
3, 6, 6, 6, 6, 6, 6, 6,12,15,15,15,15,15,15,15};
const Int_t handler_id[32] = {
0, 0, 1, 3, 2, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8,
9,10,10,10,10,10,10,10,11,12,12,12,12,12,12,12};
UChar_t *type = (UChar_t*)&mindex+3;
fHandler = handler_id[*type];
fCacheId = cache_id[*type];
fLength = cache_len[*type];
fHandlers[fHandler]->SetLocation(fCache[fCacheId]+(mindex&0x00FFFFFF)*fLength);
}
void TGeoMatrixCache::ClearMatrix(Int_t mindex)
{
if (!mindex) return;
cd(mindex);
Int_t offset = fMatrix&0x00FFFFFF;
fBitsArray[fCacheId]->SetBitNumber(offset, kFALSE);
if (UInt_t(offset)<fFree[fCacheId]) fFree[fCacheId] = offset;
}
void TGeoMatrixCache::GetMatrix(TGeoHMatrix *matrix) const
{
if (!fMatrix) {
matrix->Clear();
return;
}
Int_t matptr = fMatrix & 0x00FFFFFF;
if (!matrix->IsIdentity()) matrix->Clear();
Double_t *new_ptr = fCache[fCacheId] + matptr*fLength;
fHandlers[fHandler]->GetMatrix(new_ptr, matrix);
}
void TGeoMatrixCache::IncreaseCache()
{
UInt_t new_size = 2*fSize[fCacheId];
fBitsArray[fCacheId]->SetBitNumber(new_size-1, kFALSE);
Double_t *new_cache = new Double_t[new_size*fLength];
memcpy(new_cache, fCache[fCacheId], fSize[fCacheId]*fLength*sizeof(Double_t));
delete fCache[fCacheId];
fCache[fCacheId] = new_cache;
fSize[fCacheId] = new_size;
}
void TGeoMatrixCache::Status() const
{
Int_t ntot, ntotc,ntotused, nused, nfree, length;
printf("Matrix cache status : total used free\n");
ntot = 0;
ntotused = 0;
for (Int_t i=0; i<7; i++) {
length = 3*(i-1);
if (length == 0) length=2;
if (length < 0) length=1;
ntotc = fSize[i];
nused = fBitsArray[i]->CountBits();
nfree = ntotc-nused;
ntot += length*sizeof(Double_t)*ntotc;
ntotused += length*sizeof(Double_t)*nused;
printf(" - Cache %i : %i %i %i\n",length, ntotc,nused,nfree);
}
printf("total size : %i bytes used : %i bytes\n", ntot, ntotused);
}
ClassImp(TGeoCacheState)
TGeoCacheState::TGeoCacheState()
{
fCapacity = 0;
fLevel = 0;
fNmany = 0;
fBranch = 0;
fMatrices = 0;
fPoint = 0;
}
TGeoCacheState::TGeoCacheState(Int_t capacity)
{
fCapacity = capacity;
fLevel = 0;
fNmany = 0;
fBranch = new Int_t[capacity];
fMatrices = new Int_t[capacity];
fPoint = new Double_t[3];
}
TGeoCacheState::TGeoCacheState(const TGeoCacheState& gcs) :
TObject(gcs),
fCapacity(gcs.fCapacity),
fLevel(gcs.fLevel),
fNmany(gcs.fNmany),
fStart(gcs.fStart),
fPoint(gcs.fPoint),
fOverlapping(gcs.fOverlapping)
{
for(Int_t i=0; i<30; i++) fIdBranch[i]=gcs.fIdBranch[i];
}
TGeoCacheState& TGeoCacheState::operator=(const TGeoCacheState& gcs)
{
if(this!=&gcs) {
TObject::operator=(gcs);
fCapacity=gcs.fCapacity;
fLevel=gcs.fLevel;
fNmany=gcs.fNmany;
fStart=gcs.fStart;
for(Int_t i=0; i<30; i++) fIdBranch[i]=gcs.fIdBranch[i];
fPoint=gcs.fPoint;
fOverlapping=gcs.fOverlapping;
}
return *this;
}
TGeoCacheState::~TGeoCacheState()
{
if (fBranch) {
delete [] fBranch;
delete [] fMatrices;
delete [] fPoint;
}
}
void TGeoCacheState::SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point)
{
fLevel = level;
fStart = startlevel;
fNmany = nmany;
if (gGeoManager->IsOutside()) {
fLevel = -1;
return;
}
TGeoNodeCache *cache = gGeoManager->GetCache();
Int_t *branch = (Int_t*)cache->GetBranch();
Int_t *matrices = (Int_t*)cache->GetMatrices();
if (cache->HasIdArray()) memcpy(fIdBranch, cache->GetIdBranch()+fStart, (level+1-fStart)*sizeof(Int_t));
memcpy(fBranch, branch+fStart, (level+1-fStart)*sizeof(Int_t));
memcpy(fMatrices, matrices+fStart, (level+1-fStart)*sizeof(Int_t));
fOverlapping = ovlp;
if (point) memcpy(fPoint, point, 3*sizeof(Double_t));
}
Bool_t TGeoCacheState::GetState(Int_t &level, Int_t &nmany, Double_t *point) const
{
level = fLevel;
nmany = fNmany;
if (fLevel<0) {
level = 0;
return kFALSE;
}
TGeoNodeCache *cache = gGeoManager->GetCache();
if (cache->HasIdArray()) cache->FillIdBranch(fIdBranch, fStart);
Int_t *branch = (Int_t*)cache->GetBranch();
Int_t *matrices = (Int_t*)cache->GetMatrices();
memcpy(branch+fStart, fBranch, (level+1-fStart)*sizeof(Int_t));
memcpy(matrices+fStart, fMatrices, (level+1-fStart)*sizeof(Int_t));
if (point) memcpy(point, fPoint, 3*sizeof(Double_t));
return fOverlapping;
}
ClassImp(TGeoCacheStateDummy)
TGeoCacheStateDummy::TGeoCacheStateDummy()
{
fNodeBranch = 0;
fMatrixBranch = 0;
fMatPtr = 0;
}
TGeoCacheStateDummy::TGeoCacheStateDummy(Int_t capacity)
{
fCapacity = capacity;
fNodeBranch = new TGeoNode *[capacity];
fMatrixBranch = new TGeoHMatrix *[capacity];
fMatPtr = new TGeoHMatrix *[capacity];
for (Int_t i=0; i<capacity; i++)
fMatrixBranch[i] = new TGeoHMatrix("global");
fPoint = new Double_t[3];
}
TGeoCacheStateDummy::TGeoCacheStateDummy(const TGeoCacheStateDummy& csd) :
TGeoCacheState(csd),
fNodeBranch(csd.fNodeBranch),
fMatrixBranch(csd.fMatrixBranch),
fMatPtr(csd.fMatPtr)
{
}
TGeoCacheStateDummy& TGeoCacheStateDummy::operator=(const TGeoCacheStateDummy& csd)
{
if(this!=&csd) {
TGeoCacheState::operator=(csd);
fNodeBranch=csd.fNodeBranch;
fMatrixBranch=csd.fMatrixBranch;
fMatPtr=csd.fMatPtr;
}
return *this;
}
TGeoCacheStateDummy::~TGeoCacheStateDummy()
{
if (fNodeBranch) {
delete [] fNodeBranch;
for (Int_t i=0; i<fCapacity; i++)
delete fMatrixBranch[i];
delete [] fMatrixBranch;
delete [] fMatPtr;
delete [] fPoint;
}
}
void TGeoCacheStateDummy::SetState(Int_t level, Int_t startlevel, Int_t nmany, Bool_t ovlp, Double_t *point)
{
fLevel = level;
fStart = startlevel;
fNmany = nmany;
TGeoNodeCache *cache = gGeoManager->GetCache();
if (cache->HasIdArray()) memcpy(fIdBranch, cache->GetIdBranch()+fStart, (level+1-fStart)*sizeof(Int_t));
TGeoNode **node_branch = (TGeoNode **) cache->GetBranch();
TGeoHMatrix **mat_branch = (TGeoHMatrix **) cache->GetMatrices();
memcpy(fNodeBranch, node_branch+fStart, (level+1-fStart)*sizeof(TGeoNode *));
memcpy(fMatPtr, mat_branch+fStart, (level+1-fStart)*sizeof(TGeoHMatrix *));
TGeoHMatrix *last = 0;
TGeoHMatrix *current;
for (Int_t i=0; i<level+1-fStart; i++) {
current = mat_branch[i+fStart];
if (current == last) continue;
*fMatrixBranch[i] = current;
last = current;
}
fOverlapping = ovlp;
if (point) memcpy(fPoint, point, 3*sizeof(Double_t));
}
Bool_t TGeoCacheStateDummy::GetState(Int_t &level, Int_t &nmany, Double_t *point) const
{
level = fLevel;
nmany = fNmany;
TGeoNodeCache *cache = gGeoManager->GetCache();
if (cache->HasIdArray()) cache->FillIdBranch(fIdBranch, fStart);
TGeoNode **node_branch = (TGeoNode **) cache->GetBranch();
TGeoHMatrix **mat_branch = (TGeoHMatrix **) cache->GetMatrices();
memcpy(node_branch+fStart, fNodeBranch, (level+1-fStart)*sizeof(TGeoNode *));
memcpy(mat_branch+fStart, fMatPtr, (level+1-fStart)*sizeof(TGeoHMatrix *));
TGeoHMatrix *last = 0;
TGeoHMatrix *current;
for (Int_t i=0; i<level+1-fStart; i++) {
current = mat_branch[i+fStart];
if (current == last) continue;
*current = fMatrixBranch[i];
last = current;
}
if (point) memcpy(point, fPoint, 3*sizeof(Double_t));
return fOverlapping;
}
ClassImp(TGeoMatHandler)
ClassImp(TGeoMatHandlerId)
TGeoMatHandler::TGeoMatHandler()
{
fLocation = 0;
}
ClassImp(TGeoMatHandlerX)
void TGeoMatHandlerX::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
Double_t *translation = matrix->GetTranslation();
translation[0] = *from;
matrix->SetBit(TGeoMatrix::kGeoTranslation);
}
void TGeoMatHandlerX::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
*to = (matrix->GetTranslation())[0];
}
void TGeoMatHandlerX::LocalToMaster(const Double_t *local, Double_t *master) const
{
memcpy(master, local, 3*sizeof(Double_t));
master[0] += fLocation[0];
}
void TGeoMatHandlerX::MasterToLocal(const Double_t *master, Double_t *local) const
{
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= fLocation[0];
}
void TGeoMatHandlerX::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
gGeoManager->BombTranslation(&tr[0], &bombtr[0]);
memcpy(master, local, 3*sizeof(Double_t));
master[0] += bombtr[0];
}
void TGeoMatHandlerX::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
gGeoManager->UnbombTranslation(&tr[0], &bombtr[0]);
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= bombtr[0];
}
ClassImp(TGeoMatHandlerY)
void TGeoMatHandlerY::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
Double_t *translation = matrix->GetTranslation();
translation[1] = *from;
matrix->SetBit(TGeoMatrix::kGeoTranslation);
}
void TGeoMatHandlerY::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
*to = (matrix->GetTranslation())[1];
}
void TGeoMatHandlerY::LocalToMaster(const Double_t *local, Double_t *master) const
{
memcpy(master, local, 3*sizeof(Double_t));
master[1] += fLocation[0];
}
void TGeoMatHandlerY::MasterToLocal(const Double_t *master, Double_t *local) const
{
memcpy(local, master, 3*sizeof(Double_t));
local[1] -= fLocation[0];
}
void TGeoMatHandlerY::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[1] = fLocation[0];
gGeoManager->BombTranslation(&tr[0], &bombtr[0]);
memcpy(master, local, 3*sizeof(Double_t));
master[1] += bombtr[1];
}
void TGeoMatHandlerY::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[1] = fLocation[0];
gGeoManager->UnbombTranslation(&tr[0], &bombtr[0]);
memcpy(local, master, 3*sizeof(Double_t));
local[1] -= bombtr[1];
}
ClassImp(TGeoMatHandlerZ)
void TGeoMatHandlerZ::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
Double_t *translation = matrix->GetTranslation();
translation[2] = *from;
matrix->SetBit(TGeoMatrix::kGeoTranslation);
}
void TGeoMatHandlerZ::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
*to = (matrix->GetTranslation())[2];
}
void TGeoMatHandlerZ::LocalToMaster(const Double_t *local, Double_t *master) const
{
memcpy(master, local, 3*sizeof(Double_t));
master[2] += fLocation[0];
}
void TGeoMatHandlerZ::MasterToLocal(const Double_t *master, Double_t *local) const
{
memcpy(local, master, 3*sizeof(Double_t));
local[2] -= fLocation[0];
}
void TGeoMatHandlerZ::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[2] = fLocation[0];
gGeoManager->BombTranslation(&tr[0], &bombtr[0]);
memcpy(master, local, 3*sizeof(Double_t));
master[2] += bombtr[2];
}
void TGeoMatHandlerZ::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[2] = fLocation[0];
gGeoManager->UnbombTranslation(&tr[0], &bombtr[0]);
memcpy(local, master, 3*sizeof(Double_t));
local[2] -= bombtr[2];
}
ClassImp(TGeoMatHandlerXY)
void TGeoMatHandlerXY::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
Double_t *translation = matrix->GetTranslation();
translation[0] = from[0];
translation[1] = from[1];
matrix->SetBit(TGeoMatrix::kGeoTranslation);
}
void TGeoMatHandlerXY::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
to[0] = (matrix->GetTranslation())[0];
to[1] = (matrix->GetTranslation())[1];
}
void TGeoMatHandlerXY::LocalToMaster(const Double_t *local, Double_t *master) const
{
memcpy(master, local, 3*sizeof(Double_t));
master[0] += fLocation[0];
master[1] += fLocation[1];
}
void TGeoMatHandlerXY::MasterToLocal(const Double_t *master, Double_t *local) const
{
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= fLocation[0];
local[1] -= fLocation[1];
}
void TGeoMatHandlerXY::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
tr[1] = fLocation[1];
gGeoManager->BombTranslation(&tr[0], &bombtr[0]);
memcpy(master, local, 3*sizeof(Double_t));
master[0] += bombtr[0];
master[1] += bombtr[1];
}
void TGeoMatHandlerXY::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
tr[1] = fLocation[1];
gGeoManager->UnbombTranslation(&tr[0], &bombtr[0]);
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= bombtr[0];
local[1] -= bombtr[1];
}
ClassImp(TGeoMatHandlerXZ)
void TGeoMatHandlerXZ::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
Double_t *translation = matrix->GetTranslation();
translation[0] = from[0];
translation[2] = from[1];
matrix->SetBit(TGeoMatrix::kGeoTranslation);
}
void TGeoMatHandlerXZ::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
to[0] = (matrix->GetTranslation())[0];
to[1] = (matrix->GetTranslation())[2];
}
void TGeoMatHandlerXZ::LocalToMaster(const Double_t *local, Double_t *master) const
{
memcpy(master, local, 3*sizeof(Double_t));
master[0] += fLocation[0];
master[2] += fLocation[1];
}
void TGeoMatHandlerXZ::MasterToLocal(const Double_t *master, Double_t *local) const
{
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= fLocation[0];
local[2] -= fLocation[1];
}
void TGeoMatHandlerXZ::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
tr[2] = fLocation[1];
gGeoManager->BombTranslation(&tr[0], &bombtr[0]);
memcpy(master, local, 3*sizeof(Double_t));
master[0] += bombtr[0];
master[2] += bombtr[2];
}
void TGeoMatHandlerXZ::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
tr[2] = fLocation[1];
gGeoManager->UnbombTranslation(&tr[0], &bombtr[0]);
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= bombtr[0];
local[2] -= bombtr[2];
}
ClassImp(TGeoMatHandlerYZ)
void TGeoMatHandlerYZ::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
Double_t *translation = matrix->GetTranslation();
translation[1] = from[0];
translation[2] = from[1];
matrix->SetBit(TGeoMatrix::kGeoTranslation);
}
void TGeoMatHandlerYZ::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
to[0] = (matrix->GetTranslation())[1];
to[1] = (matrix->GetTranslation())[2];
}
void TGeoMatHandlerYZ::LocalToMaster(const Double_t *local, Double_t *master) const
{
memcpy(master, local, 3*sizeof(Double_t));
master[1] += fLocation[0];
master[2] += fLocation[1];
}
void TGeoMatHandlerYZ::MasterToLocal(const Double_t *master, Double_t *local) const
{
memcpy(local, master, 3*sizeof(Double_t));
local[1] -= fLocation[0];
local[2] -= fLocation[1];
}
void TGeoMatHandlerYZ::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[1] = fLocation[0];
tr[2] = fLocation[1];
gGeoManager->BombTranslation(&tr[0], &bombtr[0]);
memcpy(master, local, 3*sizeof(Double_t));
master[1] += bombtr[1];
master[2] += bombtr[2];
}
void TGeoMatHandlerYZ::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[1] = fLocation[0];
tr[2] = fLocation[1];
gGeoManager->UnbombTranslation(&tr[0], &bombtr[0]);
memcpy(local, master, 3*sizeof(Double_t));
local[1] -= bombtr[1];
local[2] -= bombtr[2];
}
ClassImp(TGeoMatHandlerXYZ)
void TGeoMatHandlerXYZ::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
memcpy(matrix->GetTranslation(), from, 3*sizeof(Double_t));
matrix->SetBit(TGeoMatrix::kGeoTranslation);
}
void TGeoMatHandlerXYZ::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
memcpy(to, matrix->GetTranslation(), 3*sizeof(Double_t));
}
void TGeoMatHandlerXYZ::LocalToMaster(const Double_t *local, Double_t *master) const
{
memcpy(master, local, 3*sizeof(Double_t));
master[0] += fLocation[0];
master[1] += fLocation[1];
master[2] += fLocation[2];
}
void TGeoMatHandlerXYZ::MasterToLocal(const Double_t *master, Double_t *local) const
{
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= fLocation[0];
local[1] -= fLocation[1];
local[2] -= fLocation[2];
}
void TGeoMatHandlerXYZ::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
tr[1] = fLocation[1];
tr[2] = fLocation[2];
gGeoManager->BombTranslation(&tr[0], &bombtr[0]);
memcpy(master, local, 3*sizeof(Double_t));
master[0] += bombtr[0];
master[1] += bombtr[1];
master[2] += bombtr[2];
}
void TGeoMatHandlerXYZ::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t tr[3], bombtr[3];
memset(&tr[0], 0, 3*sizeof(Double_t));
tr[0] = fLocation[0];
tr[1] = fLocation[1];
tr[2] = fLocation[2];
gGeoManager->UnbombTranslation(&tr[0], &bombtr[0]);
memcpy(local, master, 3*sizeof(Double_t));
local[0] -= bombtr[0];
local[1] -= bombtr[1];
local[2] -= bombtr[2];
}
ClassImp(TGeoMatHandlerRot)
void TGeoMatHandlerRot::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
memcpy(matrix->GetRotationMatrix(), from, 9*sizeof(Double_t));
matrix->SetBit(TGeoMatrix::kGeoRotation);
}
void TGeoMatHandlerRot::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
memcpy(to, matrix->GetRotationMatrix(), 9*sizeof(Double_t));
}
void TGeoMatHandlerRot::LocalToMaster(const Double_t *local, Double_t *master) const
{
master[0] = local[0]*fLocation[0]+local[1]*fLocation[1]+local[2]*fLocation[2];
master[1] = local[0]*fLocation[3]+local[1]*fLocation[4]+local[2]*fLocation[5];
master[2] = local[0]*fLocation[6]+local[1]*fLocation[7]+local[2]*fLocation[8];
}
void TGeoMatHandlerRot::MasterToLocal(const Double_t *master, Double_t *local) const
{
local[0] = master[0]*fLocation[0]+master[1]*fLocation[3]+master[2]*fLocation[6];
local[1] = master[0]*fLocation[1]+master[1]*fLocation[4]+master[2]*fLocation[7];
local[2] = master[0]*fLocation[2]+master[1]*fLocation[5]+master[2]*fLocation[8];
}
ClassImp(TGeoMatHandlerRotTr)
void TGeoMatHandlerRotTr::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
fLocation = from;
memcpy(matrix->GetRotationMatrix(), from, 9*sizeof(Double_t));
memcpy(matrix->GetTranslation(), from+9, 3*sizeof(Double_t));
matrix->SetBit(TGeoMatrix::kGeoTranslation);
matrix->SetBit(TGeoMatrix::kGeoRotation);
}
void TGeoMatHandlerRotTr::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
fLocation = to;
memcpy(to, matrix->GetRotationMatrix(), 9*sizeof(Double_t));
memcpy(to+9, matrix->GetTranslation(), 3*sizeof(Double_t));
}
void TGeoMatHandlerRotTr::LocalToMaster(const Double_t *local, Double_t *master) const
{
master[0] = fLocation[9] +
local[0]*fLocation[0]+local[1]*fLocation[1]+local[2]*fLocation[2];
master[1] = fLocation[10]+
local[0]*fLocation[3]+local[1]*fLocation[4]+local[2]*fLocation[5];
master[2] = fLocation[11]+
local[0]*fLocation[6]+local[1]*fLocation[7]+local[2]*fLocation[8];
}
void TGeoMatHandlerRotTr::LocalToMasterVect(const Double_t *local, Double_t *master) const
{
master[0] = local[0]*fLocation[0]+local[1]*fLocation[1]+local[2]*fLocation[2];
master[1] = local[0]*fLocation[3]+local[1]*fLocation[4]+local[2]*fLocation[5];
master[2] = local[0]*fLocation[6]+local[1]*fLocation[7]+local[2]*fLocation[8];
}
void TGeoMatHandlerRotTr::MasterToLocal(const Double_t *master, Double_t *local) const
{
local[0] = (master[0]-fLocation[9]) *fLocation[0]+
(master[1]-fLocation[10])*fLocation[3]+
(master[2]-fLocation[11])*fLocation[6];
local[1] = (master[0]-fLocation[9]) *fLocation[1]+
(master[1]-fLocation[10])*fLocation[4]+
(master[2]-fLocation[11])*fLocation[7];
local[2] = (master[0]-fLocation[9])*fLocation[2] +
(master[1]-fLocation[10])*fLocation[5]+
(master[2]-fLocation[11])*fLocation[8];
}
void TGeoMatHandlerRotTr::MasterToLocalVect(const Double_t *master, Double_t *local) const
{
local[0] = master[0]*fLocation[0]+master[1]*fLocation[3]+master[2]*fLocation[6];
local[1] = master[0]*fLocation[1]+master[1]*fLocation[4]+master[2]*fLocation[7];
local[2] = master[0]*fLocation[2]+master[1]*fLocation[5]+master[2]*fLocation[8];
}
void TGeoMatHandlerRotTr::LocalToMasterBomb(const Double_t *local, Double_t *master) const
{
Double_t bombtr[3];
gGeoManager->BombTranslation(&fLocation[9], &bombtr[0]);
master[0] = bombtr[0] +
local[0]*fLocation[0]+local[1]*fLocation[1]+local[2]*fLocation[2];
master[1] = bombtr[1]+
local[0]*fLocation[3]+local[1]*fLocation[4]+local[2]*fLocation[5];
master[2] = bombtr[2]+
local[0]*fLocation[6]+local[1]*fLocation[7]+local[2]*fLocation[8];
}
void TGeoMatHandlerRotTr::MasterToLocalBomb(const Double_t *master, Double_t *local) const
{
Double_t bombtr[3];
gGeoManager->UnbombTranslation(&fLocation[9], &bombtr[0]);
local[0] = (master[0]-bombtr[0]) *fLocation[0]+
(master[1]-bombtr[1])*fLocation[3]+
(master[2]-bombtr[2])*fLocation[6];
local[1] = (master[0]-bombtr[0]) *fLocation[1]+
(master[1]-bombtr[1])*fLocation[4]+
(master[2]-bombtr[2])*fLocation[7];
local[2] = (master[0]-bombtr[0])*fLocation[2] +
(master[1]-bombtr[1])*fLocation[5]+
(master[2]-bombtr[2])*fLocation[8];
}
ClassImp(TGeoMatHandlerScl)
void TGeoMatHandlerScl::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
memcpy(matrix->GetScale(), from, 3*sizeof(Double_t));
matrix->SetBit(TGeoMatrix::kGeoScale);
}
void TGeoMatHandlerScl::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
memcpy(to, matrix->GetScale(), 3*sizeof(Double_t));
}
ClassImp(TGeoMatHandlerTrScl)
void TGeoMatHandlerTrScl::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
memcpy(matrix->GetTranslation(), from, 3*sizeof(Double_t));
memcpy(matrix->GetScale(), from+3, 3*sizeof(Double_t));
matrix->SetBit(TGeoMatrix::kGeoTranslation);
matrix->SetBit(TGeoMatrix::kGeoScale);
}
void TGeoMatHandlerTrScl::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
memcpy(to, matrix->GetTranslation(), 3*sizeof(Double_t));
memcpy(to+3, matrix->GetScale(), 3*sizeof(Double_t));
}
ClassImp(TGeoMatHandlerRotScl)
void TGeoMatHandlerRotScl::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
memcpy(matrix->GetRotationMatrix(), from, 9*sizeof(Double_t));
memcpy(matrix->GetScale(), from+9, 3*sizeof(Double_t));
matrix->SetBit(TGeoMatrix::kGeoRotation);
matrix->SetBit(TGeoMatrix::kGeoScale);
}
void TGeoMatHandlerRotScl::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
memcpy(to, matrix->GetRotationMatrix(), 9*sizeof(Double_t));
memcpy(to+9, matrix->GetScale(), 3*sizeof(Double_t));
}
ClassImp(TGeoMatHandlerRotTrScl)
void TGeoMatHandlerRotTrScl::GetMatrix(Double_t *from, TGeoHMatrix *matrix)
{
memcpy(matrix->GetRotationMatrix(), from, 9*sizeof(Double_t));
memcpy(matrix->GetTranslation(), from+9, 3*sizeof(Double_t));
memcpy(matrix->GetScale(), from+12, 3*sizeof(Double_t));
matrix->SetBit(TGeoMatrix::kGeoTranslation);
matrix->SetBit(TGeoMatrix::kGeoRotation);
matrix->SetBit(TGeoMatrix::kGeoScale);
}
void TGeoMatHandlerRotTrScl::AddMatrix(Double_t *to, TGeoMatrix *matrix)
{
memcpy(to, matrix->GetRotationMatrix(), 9*sizeof(Double_t));
memcpy(to+9, matrix->GetTranslation(), 3*sizeof(Double_t));
memcpy(to+12, matrix->GetScale(), 3*sizeof(Double_t));
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.