#include "Riostream.h"
#include "TObject.h"
#include "TGeoMatrix.h"
#include "TGeoPara.h"
#include "TGeoArb8.h"
#include "TGeoNode.h"
#include "TGeoManager.h"
#include "TMath.h"
#include "TGeoPatternFinder.h"
ClassImp(TGeoPatternFinder)
ClassImp(TGeoPatternX)
ClassImp(TGeoPatternY)
ClassImp(TGeoPatternZ)
ClassImp(TGeoPatternParaX)
ClassImp(TGeoPatternParaY)
ClassImp(TGeoPatternParaZ)
ClassImp(TGeoPatternTrapZ)
ClassImp(TGeoPatternCylR)
ClassImp(TGeoPatternCylPhi)
ClassImp(TGeoPatternSphR)
ClassImp(TGeoPatternSphTheta)
ClassImp(TGeoPatternSphPhi)
ClassImp(TGeoPatternHoneycomb)
TGeoPatternFinder::TGeoPatternFinder()
{
fMatrix = 0;
fCurrent = -1;
fNdivisions = 0;
fDivIndex = 0;
fStep = 0;
fStart = 0;
fEnd = 0;
fVolume = 0;
fNextIndex = -1;
}
TGeoPatternFinder::TGeoPatternFinder(TGeoVolume *vol, Int_t ndiv)
{
fVolume = vol;
fMatrix = 0;
fCurrent = -1;
fNdivisions = ndiv;
fDivIndex = 0;
fStep = 0;
fStart = 0;
fEnd = 0;
fNextIndex = -1;
}
TGeoPatternFinder::TGeoPatternFinder(const TGeoPatternFinder& pf) :
TObject(pf),
fStep(pf.fStep),
fStart(pf.fStart),
fEnd(pf.fEnd),
fCurrent(pf.fCurrent),
fNdivisions(pf.fNdivisions),
fDivIndex(pf.fDivIndex),
fMatrix(pf.fMatrix),
fVolume(pf.fVolume)
{
}
TGeoPatternFinder& TGeoPatternFinder::operator=(const TGeoPatternFinder& pf)
{
if(this!=&pf) {
TObject::operator=(pf);
fStep=pf.fStep;
fStart=pf.fStart;
fEnd=pf.fEnd;
fCurrent=pf.fCurrent;
fNdivisions=pf.fNdivisions;
fDivIndex=pf.fDivIndex;
fMatrix=pf.fMatrix;
fVolume=pf.fVolume;
}
return *this;
}
TGeoPatternFinder::~TGeoPatternFinder()
{
}
TGeoNode *TGeoPatternFinder::CdNext()
{
if (fNextIndex < 0) return NULL;
cd(fNextIndex);
return GetNodeOffset(fCurrent);
}
TGeoPatternFinder *TGeoPatternFinder::MakeCopy(Bool_t)
{
return NULL;
}
TGeoPatternX::TGeoPatternX()
{
}
TGeoPatternX::TGeoPatternX(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dx = ((TGeoBBox*)vol->GetShape())->GetDX();
fStart = -dx;
fEnd = dx;
fStep = 2*dx/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternX::TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dx = ((TGeoBBox*)vol->GetShape())->GetDX();
fStart = -dx;
fEnd = fStart + ndivisions*step;
fStep = step;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternX::TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
void TGeoPatternX::cd(Int_t idiv)
{
fCurrent=idiv;
fMatrix->SetDx(fStart+idiv*fStep+0.5*fStep);
}
TGeoPatternX::~TGeoPatternX()
{
}
Bool_t TGeoPatternX::IsOnBoundary(const Double_t *point) const
{
Double_t seg = (point[0]-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternX::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Int_t ind = (Int_t)(1.+(point[0]-fStart)/fStep) - 1;
if (dir) {
fNextIndex = ind;
if (dir[0]>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
Double_t TGeoPatternX::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
{
indnext = -1;
Double_t dist = TGeoShape::Big();
if (TMath::Abs(dir[0])<TGeoShape::Tolerance()) return dist;
if (fCurrent<0) {
Error("FindNextBoundary", "Must call FindNode first");
return dist;
}
Int_t inc = (dir[0]>0)?1:0;
dist = (fStep*(fCurrent+inc)-point[0])/dir[0];
if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
if (!inc) inc = -1;
indnext = fCurrent+inc;
return dist;
}
TGeoPatternFinder *TGeoPatternX::MakeCopy(Bool_t reflect)
{
TGeoPatternX *finder = new TGeoPatternX(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternX::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 1;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternY::TGeoPatternY()
{
}
TGeoPatternY::TGeoPatternY(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dy = ((TGeoBBox*)vol->GetShape())->GetDY();
fStart = -dy;
fEnd = dy;
fStep = 2*dy/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternY::TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dy = ((TGeoBBox*)vol->GetShape())->GetDY();
fStart = -dy;
fEnd = fStart + ndivisions*step;
fStep = step;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternY::TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternY::~TGeoPatternY()
{
}
void TGeoPatternY::cd(Int_t idiv)
{
fCurrent=idiv;
fMatrix->SetDy(fStart+idiv*fStep+0.5*fStep);
}
Bool_t TGeoPatternY::IsOnBoundary(const Double_t *point) const
{
Double_t seg = (point[1]-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternY::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Int_t ind = (Int_t)(1.+(point[1]-fStart)/fStep) - 1;
if (dir) {
fNextIndex = ind;
if (dir[1]>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
Double_t TGeoPatternY::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
{
indnext = -1;
Double_t dist = TGeoShape::Big();
if (TMath::Abs(dir[1])<TGeoShape::Tolerance()) return dist;
if (fCurrent<0) {
Error("FindNextBoundary", "Must call FindNode first");
return dist;
}
Int_t inc = (dir[1]>0)?1:0;
dist = (fStep*(fCurrent+inc)-point[1])/dir[1];
if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
if (!inc) inc = -1;
indnext = fCurrent+inc;
return dist;
}
TGeoPatternFinder *TGeoPatternY::MakeCopy(Bool_t reflect)
{
TGeoPatternY *finder = new TGeoPatternY(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternY::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 2;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternZ::TGeoPatternZ()
{
}
TGeoPatternZ::TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dz = ((TGeoBBox*)vol->GetShape())->GetDZ();
fStart = -dz;
fEnd = dz;
fStep = 2*dz/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternZ::TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dz = ((TGeoBBox*)vol->GetShape())->GetDZ();
fStart = -dz;
fEnd = fStart + ndivisions*step;
fStep = step;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternZ::TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternZ::~TGeoPatternZ()
{
}
void TGeoPatternZ::cd(Int_t idiv)
{
fCurrent=idiv;
fMatrix->SetDz(((IsReflected())?-1.:1.)*(fStart+idiv*fStep+0.5*fStep));
}
Bool_t TGeoPatternZ::IsOnBoundary(const Double_t *point) const
{
Double_t seg = (point[2]-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternZ::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Int_t ind = (Int_t)(1.+(point[2]-fStart)/fStep) - 1;
if (dir) {
fNextIndex = ind;
if (dir[2]>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
Double_t TGeoPatternZ::FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext)
{
indnext = -1;
Double_t dist = TGeoShape::Big();
if (TMath::Abs(dir[2])<TGeoShape::Tolerance()) return dist;
if (fCurrent<0) {
Error("FindNextBoundary", "Must call FindNode first");
return dist;
}
Int_t inc = (dir[2]>0)?1:0;
dist = (fStep*(fCurrent+inc)-point[2])/dir[2];
if (dist<0.) Error("FindNextBoundary", "Negative distance d=%g",dist);
if (!inc) inc = -1;
indnext = fCurrent+inc;
return dist;
}
TGeoPatternFinder *TGeoPatternZ::MakeCopy(Bool_t reflect)
{
TGeoPatternZ *finder = new TGeoPatternZ(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternZ::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 3;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternParaX::TGeoPatternParaX()
{
}
TGeoPatternParaX::TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dx = ((TGeoPara*)vol->GetShape())->GetX();
fStart = -dx;
fEnd = dx;
fStep = 2*dx/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaX::TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t dx = ((TGeoPara*)vol->GetShape())->GetX();
fStart = -dx;
fEnd = fStart + ndivisions*step;
fStep = step;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaX::TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaX::~TGeoPatternParaX()
{
}
void TGeoPatternParaX::cd(Int_t idiv)
{
fCurrent=idiv;
fMatrix->SetDx(fStart+idiv*fStep+0.5*fStep);
}
Bool_t TGeoPatternParaX::IsOnBoundary(const Double_t *point) const
{
Double_t txy = ((TGeoPara*)fVolume->GetShape())->GetTxy();
Double_t txz = ((TGeoPara*)fVolume->GetShape())->GetTxz();
Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
Double_t xt = point[0]-txz*point[2]-txy*(point[1]-tyz*point[2]);
Double_t seg = (xt-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternParaX::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Double_t txy = ((TGeoPara*)fVolume->GetShape())->GetTxy();
Double_t txz = ((TGeoPara*)fVolume->GetShape())->GetTxz();
Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
Double_t xt = point[0]-txz*point[2]-txy*(point[1]-tyz*point[2]);
Int_t ind = (Int_t)(1.+(xt-fStart)/fStep)-1;
if (dir) {
Double_t ttsq = txy*txy + (txz-txy*tyz)*(txz-txy*tyz);
Double_t divdirx = 1./TMath::Sqrt(1.+ttsq);
Double_t divdiry = -txy*divdirx;
Double_t divdirz = -(txz-txy*tyz)*divdirx;
Double_t dot = dir[0]*divdirx + dir[1]*divdiry + dir[2]*divdirz;
fNextIndex = ind;
if (dot>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
TGeoPatternFinder *TGeoPatternParaX::MakeCopy(Bool_t reflect)
{
TGeoPatternParaX *finder = new TGeoPatternParaX(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternParaX::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 1;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternParaY::TGeoPatternParaY()
{
fTxy = 0;
}
TGeoPatternParaY::TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
Double_t dy = ((TGeoPara*)vol->GetShape())->GetY();
fStart = -dy;
fEnd = dy;
fStep = 2*dy/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaY::TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
Double_t dy = ((TGeoPara*)vol->GetShape())->GetY();
fStart = -dy;
fEnd = fStart + ndivisions*step;
fStep = step;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaY::TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fTxy = ((TGeoPara*)vol->GetShape())->GetTxy();
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaY::~TGeoPatternParaY()
{
}
void TGeoPatternParaY::cd(Int_t idiv)
{
fCurrent = idiv;
Double_t dy = fStart+idiv*fStep+0.5*fStep;
fMatrix->SetDx(fTxy*dy);
fMatrix->SetDy(dy);
}
Bool_t TGeoPatternParaY::IsOnBoundary(const Double_t *point) const
{
Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
Double_t yt = point[1]-tyz*point[2];
Double_t seg = (yt-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternParaY::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Double_t tyz = ((TGeoPara*)fVolume->GetShape())->GetTyz();
Double_t yt = point[1]-tyz*point[2];
Int_t ind = (Int_t)(1.+(yt-fStart)/fStep) - 1;
if (dir) {
Double_t divdiry = 1./TMath::Sqrt(1.+tyz*tyz);
Double_t divdirz = -tyz*divdiry;
Double_t dot = dir[1]*divdiry + dir[2]*divdirz;
fNextIndex = ind;
if (dot>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
TGeoPatternFinder *TGeoPatternParaY::MakeCopy(Bool_t reflect)
{
TGeoPatternParaY *finder = new TGeoPatternParaY(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternParaY::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 2;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternParaZ::TGeoPatternParaZ()
{
fTxz = 0;
fTyz = 0;
}
TGeoPatternParaZ::TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
Double_t dz = ((TGeoPara*)vol->GetShape())->GetZ();
fStart = -dz;
fEnd = dz;
fStep = 2*dz/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaZ::TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
Double_t dz = ((TGeoPara*)vol->GetShape())->GetZ();
fStart = -dz;
fEnd = fStart + ndivisions*step;
fStep = step;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaZ::TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fTxz = ((TGeoPara*)vol->GetShape())->GetTxz();
fTyz = ((TGeoPara*)vol->GetShape())->GetTyz();
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternParaZ::~TGeoPatternParaZ()
{
}
void TGeoPatternParaZ::cd(Int_t idiv)
{
fCurrent = idiv;
Double_t dz = fStart+idiv*fStep+0.5*fStep;
fMatrix->SetDx(fTxz*dz);
fMatrix->SetDy(fTyz*dz);
fMatrix->SetDz((IsReflected())?-dz:dz);
}
Bool_t TGeoPatternParaZ::IsOnBoundary(const Double_t *point) const
{
Double_t seg = (point[2]-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternParaZ::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Double_t zt = point[2];
Int_t ind = (Int_t)(1.+(zt-fStart)/fStep) - 1;
if (dir) {
fNextIndex = ind;
if (dir[2]>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
TGeoPatternFinder *TGeoPatternParaZ::MakeCopy(Bool_t reflect)
{
TGeoPatternParaZ *finder = new TGeoPatternParaZ(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternParaZ::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 3;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternTrapZ::TGeoPatternTrapZ()
{
fTxz = 0;
fTyz = 0;
}
TGeoPatternTrapZ::TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
Double_t phi = ((TGeoTrap*)vol->GetShape())->GetPhi();
fTxz = TMath::Tan(theta*TMath::DegToRad())*TMath::Cos(phi*TMath::DegToRad());
fTyz = TMath::Tan(theta*TMath::DegToRad())*TMath::Sin(phi*TMath::DegToRad());
Double_t dz = ((TGeoArb8*)vol->GetShape())->GetDz();
fStart = -dz;
fEnd = dz;
fStep = 2*dz/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternTrapZ::TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
Double_t phi = ((TGeoTrap*)vol->GetShape())->GetPhi();
fTxz = TMath::Tan(theta*TMath::DegToRad())*TMath::Cos(phi*TMath::DegToRad());
fTyz = TMath::Tan(theta*TMath::DegToRad())*TMath::Sin(phi*TMath::DegToRad());
Double_t dz = ((TGeoArb8*)vol->GetShape())->GetDz();
fStart = -dz;
fEnd = fStart + ndivisions*step;
fStep = step;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternTrapZ::TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
Double_t theta = ((TGeoTrap*)vol->GetShape())->GetTheta();
Double_t phi = ((TGeoTrap*)vol->GetShape())->GetPhi();
fTxz = TMath::Tan(theta*TMath::DegToRad())*TMath::Cos(phi*TMath::DegToRad());
fTyz = TMath::Tan(theta*TMath::DegToRad())*TMath::Sin(phi*TMath::DegToRad());
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = new TGeoTranslation(0,0,0);
fMatrix->RegisterYourself();
}
TGeoPatternTrapZ::~TGeoPatternTrapZ()
{
}
void TGeoPatternTrapZ::cd(Int_t idiv)
{
fCurrent = idiv;
Double_t dz = fStart+idiv*fStep+0.5*fStep;
fMatrix->SetDx(fTxz*dz);
fMatrix->SetDy(fTyz*dz);
fMatrix->SetDz((IsReflected())?-dz:dz);
}
Bool_t TGeoPatternTrapZ::IsOnBoundary(const Double_t *point) const
{
Double_t seg = (point[2]-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternTrapZ::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Double_t zt = point[2];
Int_t ind = (Int_t)(1. + (zt-fStart)/fStep) - 1;
if (dir) {
fNextIndex = ind;
if (dir[2]>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
TGeoPatternFinder *TGeoPatternTrapZ::MakeCopy(Bool_t reflect)
{
TGeoPatternTrapZ *finder = new TGeoPatternTrapZ(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternTrapZ::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 3;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternCylR::TGeoPatternCylR()
{
fMatrix = 0;
}
TGeoPatternCylR::TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
fMatrix = gGeoIdentity;
}
TGeoPatternCylR::TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
fStep = step;
fMatrix = gGeoIdentity;
}
TGeoPatternCylR::TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
fMatrix = gGeoIdentity;
}
TGeoPatternCylR::~TGeoPatternCylR()
{
}
Bool_t TGeoPatternCylR::IsOnBoundary(const Double_t *point) const
{
Double_t r = TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
Double_t seg = (r-fStart)/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternCylR::FindNode(Double_t *point, const Double_t *dir)
{
if (!fMatrix) fMatrix = gGeoIdentity;
TGeoNode *node = 0;
Double_t r = TMath::Sqrt(point[0]*point[0]+point[1]*point[1]);
Int_t ind = (Int_t)(1. + (r-fStart)/fStep) - 1;
if (dir) {
fNextIndex = ind;
Double_t dot = point[0]*dir[0] + point[1]*dir[1];
if (dot>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
TGeoPatternFinder *TGeoPatternCylR::MakeCopy(Bool_t reflect)
{
TGeoPatternCylR *finder = new TGeoPatternCylR(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternCylR::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 1;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternCylPhi::TGeoPatternCylPhi()
{
fSinCos = 0;
}
TGeoPatternCylPhi::TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = 0;
fEnd = 0;
fStep = 0;
fMatrix = 0;
fSinCos = 0;
}
TGeoPatternCylPhi::TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
fStep = step;
fSinCos = 0;
}
TGeoPatternCylPhi::TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
if (fStart<0) fStart+=360;
fEnd = end;
if (fEnd<0) fEnd+=360;
if ((end-start)<0)
fStep = (end-start+360)/ndivisions;
else
fStep = (end-start)/ndivisions;
fMatrix = new TGeoRotation();
fMatrix->RegisterYourself();
fSinCos = new Double_t[2*ndivisions];
for (Int_t idiv = 0; idiv<ndivisions; idiv++) {
fSinCos[2*idiv] = TMath::Sin(TMath::DegToRad()*(start+0.5*fStep+idiv*fStep));
fSinCos[2*idiv+1] = TMath::Cos(TMath::DegToRad()*(start+0.5*fStep+idiv*fStep));
}
}
TGeoPatternCylPhi::~TGeoPatternCylPhi()
{
if (fSinCos) delete [] fSinCos;
}
void TGeoPatternCylPhi::cd(Int_t idiv)
{
fCurrent = idiv;
if (!fSinCos) {
fSinCos = new Double_t[2*fNdivisions];
for (Int_t i = 0; i<fNdivisions; i++) {
fSinCos[2*i] = TMath::Sin(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
fSinCos[2*i+1] = TMath::Cos(TMath::DegToRad()*(fStart+0.5*fStep+i*fStep));
}
}
((TGeoRotation*)fMatrix)->FastRotZ(&fSinCos[2*idiv]);
}
Bool_t TGeoPatternCylPhi::IsOnBoundary(const Double_t *point) const
{
Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
if (phi<0) phi += 360;
Double_t ddp = phi - fStart;
if (ddp<0) ddp+=360;
Double_t seg = ddp/fStep;
Double_t diff = seg - Int_t(seg);
if (diff>0.5) diff = 1.-diff;
if (diff<1e-8) return kTRUE;
return kFALSE;
}
TGeoNode *TGeoPatternCylPhi::FindNode(Double_t *point, const Double_t *dir)
{
TGeoNode *node = 0;
Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
if (phi<0) phi += 360;
Double_t ddp = phi - fStart;
if (ddp<0) ddp+=360;
Int_t ind = (Int_t)(1. + ddp/fStep) - 1;
if (dir) {
fNextIndex = ind;
Double_t dot = point[0]*dir[1]-point[1]*dir[0];
if (dot>0) fNextIndex++;
else fNextIndex--;
if ((fNextIndex<0) || (fNextIndex>=fNdivisions)) fNextIndex = -1;
}
if ((ind<0) || (ind>=fNdivisions)) return node;
node = GetNodeOffset(ind);
cd(ind);
return node;
}
TGeoPatternFinder *TGeoPatternCylPhi::MakeCopy(Bool_t reflect)
{
TGeoPatternCylPhi *finder = new TGeoPatternCylPhi(*this);
if (!reflect) return finder;
Reflect();
TGeoRotation *rot = new TGeoRotation(*fMatrix);
rot->ReflectZ(kTRUE);
rot->ReflectZ(kFALSE);
rot->RegisterYourself();
fMatrix = rot;
return finder;
}
void TGeoPatternCylPhi::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 2;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternSphR::TGeoPatternSphR()
{
}
TGeoPatternSphR::TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
}
TGeoPatternSphR::TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
fStep = step;
}
TGeoPatternSphR::TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
}
TGeoPatternSphR::~TGeoPatternSphR()
{
}
TGeoNode *TGeoPatternSphR::FindNode(Double_t * , const Double_t * )
{
return 0;
}
TGeoPatternFinder *TGeoPatternSphR::MakeCopy(Bool_t reflect)
{
TGeoPatternSphR *finder = new TGeoPatternSphR(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternSphR::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 1;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternSphTheta::TGeoPatternSphTheta()
{
}
TGeoPatternSphTheta::TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
}
TGeoPatternSphTheta::TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
fStep = step;
}
TGeoPatternSphTheta::TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
}
TGeoPatternSphTheta::~TGeoPatternSphTheta()
{
}
TGeoNode *TGeoPatternSphTheta::FindNode(Double_t * , const Double_t * )
{
return 0;
}
TGeoPatternFinder *TGeoPatternSphTheta::MakeCopy(Bool_t reflect)
{
TGeoPatternSphTheta *finder = new TGeoPatternSphTheta(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternSphTheta::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 2;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternSphPhi::TGeoPatternSphPhi()
{
}
TGeoPatternSphPhi::TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions)
:TGeoPatternFinder(vol, ndivisions)
{
}
TGeoPatternSphPhi::TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step)
:TGeoPatternFinder(vol, ndivisions)
{
fStep = step;
}
TGeoPatternSphPhi::TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end)
:TGeoPatternFinder(vol, ndivisions)
{
fStart = start;
fEnd = end;
fStep = (end - start)/ndivisions;
}
TGeoPatternSphPhi::~TGeoPatternSphPhi()
{
}
TGeoNode *TGeoPatternSphPhi::FindNode(Double_t * , const Double_t * )
{
return 0;
}
TGeoPatternFinder *TGeoPatternSphPhi::MakeCopy(Bool_t reflect)
{
TGeoPatternSphPhi *finder = new TGeoPatternSphPhi(*this);
if (!reflect) return finder;
Reflect();
TGeoCombiTrans *combi = new TGeoCombiTrans(*fMatrix);
combi->ReflectZ(kTRUE);
combi->ReflectZ(kFALSE);
combi->RegisterYourself();
fMatrix = combi;
return finder;
}
void TGeoPatternSphPhi::SavePrimitive(ostream &out, Option_t * )
{
Int_t iaxis = 3;
out << iaxis << ", " << fNdivisions << ", " << fStart << ", " << fStep;
}
TGeoPatternHoneycomb::TGeoPatternHoneycomb()
{
fNrows = 0;
fAxisOnRows = 0;
fNdivisions = 0;
fStart = 0;
}
TGeoPatternHoneycomb::TGeoPatternHoneycomb(TGeoVolume *vol, Int_t nrows)
:TGeoPatternFinder(vol, nrows)
{
fNrows = nrows;
}
TGeoPatternHoneycomb::TGeoPatternHoneycomb(const TGeoPatternHoneycomb& pfh) :
TGeoPatternFinder(pfh),
fNrows(pfh.fNrows),
fAxisOnRows(pfh.fAxisOnRows),
fNdivisions(pfh.fNdivisions),
fStart(pfh.fStart)
{
}
TGeoPatternHoneycomb& TGeoPatternHoneycomb::operator=(const TGeoPatternHoneycomb& pfh)
{
if(this!=&pfh) {
TGeoPatternFinder::operator=(pfh);
fNrows=pfh.fNrows;
fAxisOnRows=pfh.fAxisOnRows;
fNdivisions=pfh.fNdivisions;
fStart=pfh.fStart;
}
return *this;
}
TGeoPatternHoneycomb::~TGeoPatternHoneycomb()
{
}
TGeoNode *TGeoPatternHoneycomb::FindNode(Double_t * , const Double_t * )
{
return 0;
}
Last change: Fri Oct 10 15:52:12 2008
Last generated: 2008-10-10 15:52
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.