TGeoNavigator.h

Go to the documentation of this file.
00001 // @(#)root/geom:$Id: TGeoNavigator.h 31002 2009-11-06 09:27:30Z brun $
00002 // Author: Mihaela Gheata   30/05/07
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGeoNavigator
00013 #define ROOT_TGeoNavigator
00014 
00015 #ifndef ROOT_TObject
00016 #include "TObject.h"
00017 #endif
00018 
00019 #ifndef ROOT_TGeoNodeCache
00020 #include "TGeoCache.h"
00021 #endif
00022 
00023 ////////////////////////////////////////////////////////////////////////////
00024 //                                                                        //
00025 // TGeoNavigator - Class containing the implementation of all navigation  //
00026 //   methods.
00027 //                                                                        //
00028 ////////////////////////////////////////////////////////////////////////////
00029 
00030 class TGeoManager;
00031 class TGeoNode;
00032 class TGeoVolume;
00033 class TGeoMatrix;
00034 class TGeoHMatrix;
00035 
00036 
00037 class TGeoNavigator : public TObject
00038 {
00039 
00040 protected:
00041    TGeoNavigator(const TGeoNavigator&); 
00042    TGeoNavigator& operator=(const TGeoNavigator&); 
00043    TGeoNode             *FindInCluster(Int_t *cluster, Int_t nc);
00044    Int_t                 GetTouchedCluster(Int_t start, Double_t *point, Int_t *check_list,
00045                                            Int_t ncheck, Int_t *result);
00046    TGeoNode             *CrossDivisionCell();
00047    void                  SafetyOverlaps();
00048 
00049 private :
00050    Double_t              fStep;             //! step to be done from current point and direction
00051    Double_t              fSafety;           //! safety radius from current point
00052    Double_t              fLastSafety;       //! last computed safety radius
00053    Double_t              fNormal[3];        //! cosine of incident angle on current checked surface
00054    Double_t              fCldir[3];         //! unit vector to current closest shape
00055    Double_t              fCldirChecked[3];  //! unit vector to current checked shape
00056    Double_t              fPoint[3];         //! current point
00057    Double_t              fDirection[3];     //! current direction
00058    Double_t              fLastPoint[3];     //! last point for which safety was computed
00059    Int_t                 fLevel;            //! current geometry level;
00060    Int_t                 fNmany;            //! number of overlapping nodes on current branch
00061    Int_t                 fNextDaughterIndex; //! next daughter index after FindNextBoundary
00062    Int_t                 fOverlapSize;      //! current size of fOverlapClusters
00063    Int_t                 fOverlapMark;      //! current recursive position in fOverlapClusters
00064    Int_t                *fOverlapClusters;  //! internal array for overlaps
00065    Bool_t                fSearchOverlaps;   //! flag set when an overlapping cluster is searched
00066    Bool_t                fCurrentOverlapping; //! flags the type of the current node
00067    Bool_t                fStartSafe;        //! flag a safe start for point classification
00068    Bool_t                fIsEntering;       //! flag if current step just got into a new node
00069    Bool_t                fIsExiting;        //! flag that current track is about to leave current node
00070    Bool_t                fIsStepEntering;   //! flag that next geometric step will enter new volume
00071    Bool_t                fIsStepExiting;    //! flaag that next geometric step will exit current volume
00072    Bool_t                fIsOutside;        //! flag that current point is outside geometry
00073    Bool_t                fIsOnBoundary;     //! flag that current point is on some boundary
00074    Bool_t                fIsSameLocation;   //! flag that a new point is in the same node as previous
00075    Bool_t                fIsNullStep;       //! flag that last geometric step was null
00076    TGeoManager          *fGeometry;         //! current geometry
00077    TGeoNodeCache        *fCache;            //! cache of states
00078    TGeoVolume           *fCurrentVolume;    //! current volume
00079    TGeoNode             *fCurrentNode;      //! current node    
00080    TGeoNode             *fTopNode;          //! top physical node
00081    TGeoNode             *fLastNode;         //! last searched node
00082    TGeoNode             *fNextNode;         //! next node that will be crossed
00083    TGeoNode             *fForcedNode;       //! current point is supposed to be inside this node
00084    TGeoCacheState       *fBackupState;      //! backup state
00085    TGeoHMatrix          *fCurrentMatrix;    //! current stored global matrix
00086    TGeoHMatrix          *fGlobalMatrix;     //! current pointer to cached global matrix
00087    TString               fPath;             //! path to current node
00088     
00089 public :
00090    TGeoNavigator();
00091    TGeoNavigator(TGeoManager* geom);
00092    virtual ~TGeoNavigator();
00093 
00094    void                   BuildCache(Bool_t dummy=kFALSE, Bool_t nodeid=kFALSE);
00095    Bool_t                 cd(const char *path="");
00096    Bool_t                 CheckPath(const char *path) const;
00097    void                   CdNode(Int_t nodeid);
00098    void                   CdDown(Int_t index);
00099    void                   CdUp();
00100    void                   CdTop();
00101    void                   CdNext();
00102    void                   GetBranchNames(Int_t *names) const;
00103    void                   GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const;
00104    void                   GetBranchOnlys(Int_t *isonly) const;
00105    Int_t                  GetNmany() const {return fNmany;}
00106    //--- geometry queries
00107    TGeoNode              *CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode);
00108    TGeoNode              *FindNextBoundary(Double_t stepmax=TGeoShape::Big(),const char *path="", Bool_t frombdr=kFALSE);
00109    TGeoNode              *FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE);
00110    TGeoNode              *FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE);
00111    TGeoNode              *FindNode(Bool_t safe_start=kTRUE);
00112    TGeoNode              *FindNode(Double_t x, Double_t y, Double_t z);
00113    Double_t              *FindNormal(Bool_t forward=kTRUE);
00114    Double_t              *FindNormalFast();
00115    TGeoNode              *InitTrack(const Double_t *point, const Double_t *dir);
00116    TGeoNode              *InitTrack(Double_t x, Double_t y, Double_t z, Double_t nx, Double_t ny, Double_t nz);
00117    void                   ResetState();
00118    void                   ResetAll();
00119    Double_t               Safety(Bool_t inside=kFALSE);
00120    TGeoNode              *SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=0);
00121    TGeoNode              *Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE);
00122    const Double_t        *GetLastPoint() const {return fLastPoint;}
00123    Int_t                  GetVirtualLevel();
00124    Bool_t                 GotoSafeLevel();
00125    Int_t                  GetSafeLevel() const;
00126    Double_t               GetSafeDistance() const      {return fSafety;}
00127    Double_t               GetLastSafety() const        {return fLastSafety;}
00128    Double_t               GetStep() const              {return fStep;}
00129    void                   InspectState() const;
00130    Bool_t                 IsSafeStep(Double_t proposed, Double_t &newsafety) const;
00131    Bool_t                 IsSameLocation(Double_t x, Double_t y, Double_t z, Bool_t change=kFALSE);
00132    Bool_t                 IsSameLocation() const {return fIsSameLocation;}
00133    Bool_t                 IsSamePoint(Double_t x, Double_t y, Double_t z) const;
00134    Bool_t                 IsStartSafe() const {return fStartSafe;}
00135    void                   SetStartSafe(Bool_t flag=kTRUE)   {fStartSafe=flag;}
00136    void                   SetStep(Double_t step) {fStep=step;}
00137    Bool_t                 IsCheckingOverlaps() const   {return fSearchOverlaps;}
00138    Bool_t                 IsCurrentOverlapping() const {return fCurrentOverlapping;}
00139    Bool_t                 IsEntering() const           {return fIsEntering;}
00140    Bool_t                 IsExiting() const            {return fIsExiting;}
00141    Bool_t                 IsStepEntering() const       {return fIsStepEntering;}
00142    Bool_t                 IsStepExiting() const        {return fIsStepExiting;}
00143    Bool_t                 IsOutside() const            {return fIsOutside;}
00144    Bool_t                 IsOnBoundary() const         {return fIsOnBoundary;}
00145    Bool_t                 IsNullStep() const           {return fIsNullStep;}
00146    void                   SetCheckingOverlaps(Bool_t flag=kTRUE) {fSearchOverlaps = flag;}
00147    void                   SetOutside(Bool_t flag=kTRUE) {fIsOutside = flag;}
00148    //--- modeler state getters/setters
00149    void                   DoBackupState();
00150    void                   DoRestoreState();
00151    Int_t                  GetNodeId() const           {return fCache->GetNodeId();}
00152    TGeoNode              *GetNextNode() const         {return fNextNode;}
00153    TGeoNode              *GetMother(Int_t up=1) const {return fCache->GetMother(up);}
00154    TGeoHMatrix           *GetMotherMatrix(Int_t up=1) const {return fCache->GetMotherMatrix(up);}
00155    TGeoHMatrix           *GetHMatrix();
00156    TGeoHMatrix           *GetCurrentMatrix() const    {return fCache->GetCurrentMatrix();}
00157    TGeoNode              *GetCurrentNode() const      {return fCurrentNode;}
00158    Int_t                  GetCurrentNodeId() const    {return fCache->GetCurrentNodeId();}
00159    const Double_t        *GetCurrentPoint() const     {return fPoint;}
00160    const Double_t        *GetCurrentDirection() const {return fDirection;}
00161    TGeoVolume            *GetCurrentVolume() const {return fCurrentNode->GetVolume();}
00162    const Double_t        *GetCldirChecked() const  {return fCldirChecked;}
00163    const Double_t        *GetCldir() const         {return fCldir;}
00164 //   Double_t               GetNormalChecked() const {return fNormalChecked;}
00165    const Double_t        *GetNormal() const        {return fNormal;}
00166    Int_t                  GetLevel() const         {return fLevel;}
00167    const char            *GetPath() const;
00168    Int_t                  GetStackLevel() const    {return fCache->GetStackLevel();}
00169    void                   SetCurrentPoint(const Double_t *point) {memcpy(fPoint,point,3*sizeof(Double_t));}
00170    void                   SetCurrentPoint(Double_t x, Double_t y, Double_t z) {
00171                                     fPoint[0]=x; fPoint[1]=y; fPoint[2]=z;}
00172    void                   SetLastPoint(Double_t x, Double_t y, Double_t z) {
00173                                     fLastPoint[0]=x; fLastPoint[1]=y; fLastPoint[2]=z;}
00174    void                   SetCurrentDirection(const Double_t *dir) {memcpy(fDirection,dir,3*sizeof(Double_t));}
00175    void                   SetCurrentDirection(Double_t nx, Double_t ny, Double_t nz) {
00176                                     fDirection[0]=nx; fDirection[1]=ny; fDirection[2]=nz;}
00177 //   void                   SetNormalChecked(Double_t norm) {fNormalChecked=norm;}
00178    void                   SetCldirChecked(Double_t *dir) {memcpy(fCldirChecked, dir, 3*sizeof(Double_t));}
00179 
00180    //--- point/vector reference frame conversion
00181    void                   LocalToMaster(const Double_t *local, Double_t *master) const {fCache->LocalToMaster(local, master);}
00182    void                   LocalToMasterVect(const Double_t *local, Double_t *master) const {fCache->LocalToMasterVect(local, master);}
00183    void                   LocalToMasterBomb(const Double_t *local, Double_t *master) const {fCache->LocalToMasterBomb(local, master);}
00184    void                   MasterToLocal(const Double_t *master, Double_t *local) const {fCache->MasterToLocal(master, local);}
00185    void                   MasterToLocalVect(const Double_t *master, Double_t *local) const {fCache->MasterToLocalVect(master, local);}
00186    void                   MasterToLocalBomb(const Double_t *master, Double_t *local) const {fCache->MasterToLocalBomb(master, local);}
00187    void                   MasterToTop(const Double_t *master, Double_t *top) const;
00188    void                   TopToMaster(const Double_t *top, Double_t *master) const;
00189    TGeoNodeCache         *GetCache() const         {return fCache;}
00190 //   void                   SetCache(const TGeoNodeCache *cache) {fCache = (TGeoNodeCache*)cache;}
00191    //--- stack manipulation
00192    Int_t                  PushPath(Int_t startlevel=0) {return fCache->PushState(fCurrentOverlapping, startlevel, fNmany);}
00193    Bool_t                 PopPath() {fCurrentOverlapping=fCache->PopState(fNmany); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel();fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00194    Bool_t                 PopPath(Int_t index) {fCurrentOverlapping=fCache->PopState(fNmany,index); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel();fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00195    Int_t                  PushPoint(Int_t startlevel=0) {return fCache->PushState(fCurrentOverlapping, startlevel,fNmany,fPoint);}
00196    Bool_t                 PopPoint() {fCurrentOverlapping=fCache->PopState(fNmany,fPoint); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel(); fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00197    Bool_t                 PopPoint(Int_t index) {fCurrentOverlapping=fCache->PopState(fNmany,index, fPoint); fCurrentNode=fCache->GetNode(); fLevel=fCache->GetLevel(); fGlobalMatrix=fCache->GetCurrentMatrix();return fCurrentOverlapping;}
00198    void                   PopDummy(Int_t ipop=9999) {fCache->PopDummy(ipop);}
00199    
00200    ClassDef(TGeoNavigator, 0)          // geometry navigator class
00201 };
00202 
00203 #endif
00204    

Generated on Tue Jul 5 14:12:18 2011 for ROOT_528-00b_version by  doxygen 1.5.1