#ifndef ROOT_TGeoPatternFinder
#define ROOT_TGeoPatternFinder
#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TGeoVolume
#include "TGeoVolume.h"
#endif
class TGeoMatrix;
class TGeoPatternFinder : public TObject
{
public:
struct ThreadData_t
{
TGeoMatrix *fMatrix;
Int_t fCurrent;
Int_t fNextIndex;
ThreadData_t();
~ThreadData_t();
private:
ThreadData_t(const ThreadData_t&);
ThreadData_t& operator=(const ThreadData_t&);
};
ThreadData_t& GetThreadData() const;
void ClearThreadData() const;
void CreateThreadData(Int_t nthreads);
protected :
enum EGeoPatternFlags {
kPatternReflected = BIT(14),
kPatternSpacedOut = BIT(15)
};
Double_t fStep;
Double_t fStart;
Double_t fEnd;
Int_t fNdivisions;
Int_t fDivIndex;
TGeoVolume *fVolume;
mutable std::vector<ThreadData_t*> fThreadData;
mutable Int_t fThreadSize;
protected:
TGeoPatternFinder(const TGeoPatternFinder&);
TGeoPatternFinder& operator=(const TGeoPatternFinder&);
public:
TGeoPatternFinder();
TGeoPatternFinder(TGeoVolume *vol, Int_t ndiv);
virtual ~TGeoPatternFinder();
virtual TGeoMatrix* CreateMatrix() const = 0;
virtual void cd(Int_t ) {}
virtual TGeoNode *CdNext();
virtual TGeoNode *FindNode(Double_t * , const Double_t * =0) {return 0;}
virtual Int_t GetByteCount() const {return 36;}
Int_t GetCurrent();
Int_t GetDivIndex() {return fDivIndex;}
virtual Int_t GetDivAxis() {return 1;}
virtual TGeoMatrix *GetMatrix();
Int_t GetNdiv() const {return fNdivisions;}
Int_t GetNext() const;
TGeoNode *GetNodeOffset(Int_t idiv) {return fVolume->GetNode(fDivIndex+idiv);}
Double_t GetStart() const {return fStart;}
Double_t GetStep() const {return fStep;}
Double_t GetEnd() const {return fEnd;}
TGeoVolume *GetVolume() const {return fVolume;}
virtual Bool_t IsOnBoundary(const Double_t * ) const {return kFALSE;}
Bool_t IsReflected() const {return TObject::TestBit(kPatternReflected);}
Bool_t IsSpacedOut() const {return TObject::TestBit(kPatternSpacedOut);}
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE) = 0;
void Reflect(Bool_t flag=kTRUE) {TObject::SetBit(kPatternReflected,flag);}
void SetDivIndex(Int_t index) {fDivIndex = index;}
void SetNext(Int_t index);
void SetRange(Double_t start, Double_t step, Int_t ndivisions);
void SetSpacedOut(Bool_t flag) {TObject::SetBit(kPatternSpacedOut,flag);}
void SetVolume(TGeoVolume *vol) {fVolume = vol;}
virtual void UpdateMatrix(Int_t , TGeoHMatrix &) const {}
ClassDef(TGeoPatternFinder, 4)
};
class TGeoTranslation;
class TGeoPatternX : public TGeoPatternFinder
{
public:
TGeoPatternX();
TGeoPatternX(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternX(const TGeoPatternX &pf);
TGeoPatternX& operator=(const TGeoPatternX&);
virtual ~TGeoPatternX();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext);
virtual Int_t GetDivAxis() {return 1;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternX, 1)
};
class TGeoPatternY : public TGeoPatternFinder
{
public:
TGeoPatternY();
TGeoPatternY(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternY(const TGeoPatternY &pf);
TGeoPatternY& operator=(const TGeoPatternY&);
virtual ~TGeoPatternY();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext);
virtual Int_t GetDivAxis() {return 2;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternY, 1)
};
class TGeoPatternZ : public TGeoPatternFinder
{
public:
TGeoPatternZ();
TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternZ(const TGeoPatternZ &pf);
TGeoPatternZ& operator=(const TGeoPatternZ&);
virtual ~TGeoPatternZ();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Double_t FindNextBoundary(Double_t *point, Double_t *dir, Int_t &indnext);
virtual Int_t GetDivAxis() {return 3;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternZ, 1)
};
class TGeoPatternParaX : public TGeoPatternFinder
{
public:
TGeoPatternParaX();
TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternParaX(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternParaX(const TGeoPatternParaX &pf);
TGeoPatternParaX& operator=(const TGeoPatternParaX&);
virtual ~TGeoPatternParaX();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 1;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternParaX, 1)
};
class TGeoPatternParaY : public TGeoPatternFinder
{
private :
Double_t fTxy;
public:
TGeoPatternParaY();
TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternParaY(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternParaY(const TGeoPatternParaY &pf);
TGeoPatternParaY& operator=(const TGeoPatternParaY&);
virtual ~TGeoPatternParaY();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 2;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternParaY, 1)
};
class TGeoPatternParaZ : public TGeoPatternFinder
{
private :
Double_t fTxz;
Double_t fTyz;
public:
TGeoPatternParaZ();
TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternParaZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternParaZ(const TGeoPatternParaZ &pf);
TGeoPatternParaZ& operator=(const TGeoPatternParaZ&);
virtual ~TGeoPatternParaZ();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 3;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternParaZ, 1)
};
class TGeoPatternTrapZ : public TGeoPatternFinder
{
private :
Double_t fTxz;
Double_t fTyz;
public:
TGeoPatternTrapZ();
TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternTrapZ(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternTrapZ(const TGeoPatternTrapZ &pf);
TGeoPatternTrapZ& operator=(const TGeoPatternTrapZ&);
virtual ~TGeoPatternTrapZ();
virtual TGeoMatrix* CreateMatrix() const;
Double_t GetTxz() const {return fTxz;}
Double_t GetTyz() const {return fTyz;}
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 3;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternTrapZ, 1)
};
class TGeoPatternCylR : public TGeoPatternFinder
{
public:
TGeoPatternCylR();
TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternCylR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternCylR(const TGeoPatternCylR &pf);
TGeoPatternCylR& operator=(const TGeoPatternCylR&);
virtual ~TGeoPatternCylR();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 1;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternCylR, 1)
};
class TGeoPatternCylPhi : public TGeoPatternFinder
{
private :
Double_t *fSinCos;
protected:
TGeoPatternCylPhi(const TGeoPatternCylPhi& pfc)
: TGeoPatternFinder(pfc), fSinCos(pfc.fSinCos) {CreateThreadData(1);}
TGeoPatternCylPhi& operator=(const TGeoPatternCylPhi& pfc)
{if(this!=&pfc) {TGeoPatternFinder::operator=(pfc); fSinCos=pfc.fSinCos; CreateThreadData(1);}
return *this;}
public:
TGeoPatternCylPhi();
TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternCylPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
virtual ~TGeoPatternCylPhi();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 2;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternCylPhi, 1)
};
class TGeoPatternSphR : public TGeoPatternFinder
{
public:
TGeoPatternSphR();
TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternSphR(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternSphR(const TGeoPatternSphR &pf);
TGeoPatternSphR& operator=(const TGeoPatternSphR&);
virtual ~TGeoPatternSphR();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 1;}
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternSphR, 1)
};
class TGeoPatternSphTheta : public TGeoPatternFinder
{
public:
TGeoPatternSphTheta();
TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternSphTheta(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
TGeoPatternSphTheta(const TGeoPatternSphTheta &pf);
TGeoPatternSphTheta& operator=(const TGeoPatternSphTheta&);
virtual ~TGeoPatternSphTheta();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 3;}
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternSphTheta, 1)
};
class TGeoPatternSphPhi : public TGeoPatternFinder
{
private:
Double_t *fSinCos;
protected:
TGeoPatternSphPhi(const TGeoPatternSphPhi& pfc);
TGeoPatternSphPhi& operator=(const TGeoPatternSphPhi& pfc);
Double_t *CreateSinCos();
public:
TGeoPatternSphPhi();
TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions);
TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t step);
TGeoPatternSphPhi(TGeoVolume *vol, Int_t ndivisions, Double_t start, Double_t end);
virtual ~TGeoPatternSphPhi();
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual Int_t GetDivAxis() {return 2;}
virtual Bool_t IsOnBoundary(const Double_t *point) const;
virtual
TGeoPatternFinder *MakeCopy(Bool_t reflect=kFALSE);
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternSphPhi, 1)
};
class TGeoPatternHoneycomb : public TGeoPatternFinder
{
private :
Int_t fNrows;
Int_t fAxisOnRows;
Int_t *fNdivisions;
Double_t *fStart;
protected:
TGeoPatternHoneycomb(const TGeoPatternHoneycomb&);
TGeoPatternHoneycomb& operator=(const TGeoPatternHoneycomb&);
public:
TGeoPatternHoneycomb();
TGeoPatternHoneycomb(TGeoVolume *vol, Int_t nrows);
virtual ~TGeoPatternHoneycomb();
TGeoPatternFinder *MakeCopy(Bool_t) {return 0;}
virtual TGeoMatrix* CreateMatrix() const;
virtual void cd(Int_t idiv);
virtual TGeoNode *FindNode(Double_t *point, const Double_t *dir=0);
virtual void UpdateMatrix(Int_t idiv, TGeoHMatrix &matrix) const;
ClassDef(TGeoPatternHoneycomb, 1)
};
#endif