00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGeoNode
00013 #define ROOT_TGeoNode
00014
00015 #ifndef ROOT_Riosfwd
00016 #include "Riosfwd.h"
00017 #endif
00018
00019 #ifndef ROOT_TGeoAtt
00020 #include "TGeoAtt.h"
00021 #endif
00022
00023 #ifndef ROOT_TNamed
00024 #include "TNamed.h"
00025 #endif
00026
00027 #ifndef ROOT_TGeoVolume
00028 #include "TGeoVolume.h"
00029 #endif
00030
00031 #ifndef ROOT_TGeoPatternFinder
00032 #include "TGeoPatternFinder.h"
00033 #endif
00034
00035
00036 class TString;
00037 class TGeoVolume;
00038 class TGeoShape;
00039 class TGeoMedium;
00040 class TGeoMatrix;
00041 class TGeoHMatrix;
00042
00043
00044
00045
00046
00047
00048
00049
00050 class TGeoNode : public TNamed,
00051 public TGeoAtt
00052 {
00053 protected:
00054 TGeoVolume *fVolume;
00055 TGeoVolume *fMother;
00056 Int_t fNumber;
00057 Int_t fNovlp;
00058 Int_t *fOverlaps;
00059
00060 TGeoNode(const TGeoNode&);
00061 TGeoNode& operator=(const TGeoNode&);
00062
00063 public:
00064 enum {
00065 kGeoNodeMatrix = BIT(10),
00066 kGeoNodeOffset = BIT(11),
00067 kGeoNodeVC = BIT(12),
00068 kGeoNodeOverlap = BIT(13)
00069 };
00070
00071
00072 TGeoNode();
00073 TGeoNode(const TGeoVolume *vol);
00074
00075 virtual ~TGeoNode();
00076
00077 void Browse(TBrowser *b);
00078 virtual void cd() const {;}
00079 void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="");
00080 void CheckShapes();
00081 Int_t CountDaughters(Bool_t unique_volumes=kFALSE);
00082 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
00083 void Draw(Option_t *option="");
00084 void DrawOnly(Option_t *option="");
00085 void DrawOverlaps();
00086 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
00087 void FillIdArray(Int_t &ifree, Int_t &nodeid, Int_t *array) const;
00088 Int_t FindNode(const TGeoNode *node, Int_t level);
00089 virtual Int_t GetByteCount() const {return 44;}
00090 TGeoNode *GetDaughter(Int_t ind) const {return fVolume->GetNode(ind);}
00091 virtual TGeoMatrix *GetMatrix() const = 0;
00092
00093 Int_t GetColour() const {return fVolume->GetLineColor();}
00094 virtual Int_t GetIndex() const {return 0;}
00095 virtual TGeoPatternFinder *GetFinder() const {return 0;}
00096 TGeoMedium *GetMedium() const {return fVolume->GetMedium();}
00097 TGeoVolume *GetMotherVolume() const {return fMother;}
00098 Int_t GetNdaughters() const {return fVolume->GetNdaughters();}
00099 TObjArray *GetNodes() const {return fVolume->GetNodes();}
00100 Int_t GetNumber() const {return fNumber;}
00101 Int_t *GetOverlaps(Int_t &novlp) const {novlp=fNovlp; return fOverlaps;}
00102 TGeoVolume *GetVolume() const {return fVolume;}
00103 virtual char *GetObjectInfo(Int_t px, Int_t py) const;
00104 virtual Int_t GetOptimalVoxels() const {return 0;}
00105 void InspectNode() const;
00106 virtual Bool_t IsFolder() const {return (GetNdaughters()?kTRUE:kFALSE);}
00107 Bool_t IsOffset() const {return TObject::TestBit(kGeoNodeOffset);}
00108 Bool_t IsOnScreen() const;
00109 Bool_t IsOverlapping() const {return TObject::TestBit(kGeoNodeOverlap);}
00110 Bool_t IsVirtual() const {return TObject::TestBit(kGeoNodeVC);}
00111 Bool_t IsVisible() const {return (TGeoAtt::IsVisible() && fVolume->IsVisible());}
00112 Bool_t IsVisDaughters() const {return (TGeoAtt::IsVisDaughters() && fVolume->IsVisDaughters());}
00113 Bool_t MayOverlap(Int_t iother) const;
00114
00115 virtual TGeoNode *MakeCopyNode() const {return 0;}
00116 Double_t Safety(Double_t *point, Bool_t in=kTRUE) const;
00117 void SaveAttributes(ostream &out);
00118 void SetCurrentPoint(Double_t x, Double_t y, Double_t z) {fVolume->SetCurrentPoint(x,y,z);}
00119 void SetVolume(TGeoVolume *volume) {fVolume = volume;}
00120 void SetNumber(Int_t number) {fNumber=number;}
00121 void SetOverlapping(Bool_t flag=kTRUE) {TObject::SetBit(kGeoNodeOverlap, flag);}
00122 void SetVirtual() {TObject::SetBit(kGeoNodeVC, kTRUE);}
00123 void SetVisibility(Bool_t vis=kTRUE);
00124 void SetInvisible() {SetVisibility(kFALSE);}
00125 void SetAllInvisible() {VisibleDaughters(kFALSE);}
00126 void SetMotherVolume(TGeoVolume *mother) {fMother = mother;}
00127 void SetOverlaps(Int_t *ovlp, Int_t novlp);
00128
00129 virtual void MasterToLocal(const Double_t *master, Double_t *local) const;
00130 virtual void MasterToLocalVect(const Double_t *master, Double_t *local) const;
00131 virtual void LocalToMaster(const Double_t *local, Double_t *master) const;
00132 virtual void LocalToMasterVect(const Double_t *local, Double_t *master) const;
00133
00134 virtual void ls(Option_t *option = "") const;
00135 virtual void Paint(Option_t *option = "");
00136 void PrintCandidates() const;
00137 void PrintOverlaps() const;
00138 void VisibleDaughters(Bool_t vis=kTRUE);
00139
00140 ClassDef(TGeoNode, 2)
00141 };
00142
00143
00144
00145
00146
00147
00148
00149 class TGeoNodeMatrix : public TGeoNode
00150 {
00151 private:
00152 TGeoMatrix *fMatrix;
00153
00154 protected:
00155 TGeoNodeMatrix(const TGeoNodeMatrix& gnm);
00156 TGeoNodeMatrix& operator=(const TGeoNodeMatrix& gnm);
00157
00158 public:
00159
00160 TGeoNodeMatrix();
00161 TGeoNodeMatrix(const TGeoVolume *vol, const TGeoMatrix *matrix);
00162
00163 virtual ~TGeoNodeMatrix();
00164
00165 virtual Int_t GetByteCount() const;
00166 virtual Int_t GetOptimalVoxels() const;
00167 virtual Bool_t IsFolder() const {return kTRUE;}
00168 virtual TGeoMatrix *GetMatrix() const {return fMatrix;}
00169 virtual TGeoNode *MakeCopyNode() const;
00170 void SetMatrix(const TGeoMatrix *matrix);
00171
00172 ClassDef(TGeoNodeMatrix, 1)
00173 };
00174
00175
00176
00177
00178
00179
00180
00181 class TGeoNodeOffset : public TGeoNode
00182 {
00183 private:
00184 Double_t fOffset;
00185 Int_t fIndex;
00186 TGeoPatternFinder *fFinder;
00187
00188 protected:
00189 TGeoNodeOffset(const TGeoNodeOffset&);
00190 TGeoNodeOffset& operator=(const TGeoNodeOffset&);
00191
00192 public:
00193
00194 TGeoNodeOffset();
00195 TGeoNodeOffset(const TGeoVolume *vol, Int_t index, Double_t offset);
00196
00197 virtual ~TGeoNodeOffset();
00198
00199 virtual void cd() const {fFinder->cd(fIndex);}
00200 Double_t GetOffset() const {return fOffset;}
00201 virtual Int_t GetIndex() const;
00202 virtual TGeoPatternFinder *GetFinder() const {return fFinder;}
00203 virtual TGeoMatrix *GetMatrix() const {cd(); return fFinder->GetMatrix();}
00204 virtual TGeoNode *MakeCopyNode() const;
00205 void SetFinder(const TGeoPatternFinder *finder) {fFinder = (TGeoPatternFinder*)finder;}
00206
00207 ClassDef(TGeoNodeOffset, 1)
00208 };
00209
00210
00211
00212
00213
00214
00215
00216
00217 class TGeoIterator;
00218
00219 class TGeoIteratorPlugin : public TObject
00220 {
00221 protected:
00222 const TGeoIterator *fIterator;
00223 private:
00224
00225 TGeoIteratorPlugin(const TGeoIteratorPlugin &);
00226 TGeoIteratorPlugin &operator=(const TGeoIteratorPlugin &);
00227 public:
00228 TGeoIteratorPlugin() : TObject(),fIterator(0) {}
00229 virtual ~TGeoIteratorPlugin() {}
00230
00231 virtual void ProcessNode() = 0;
00232 void SetIterator(const TGeoIterator *iter) {fIterator = iter;}
00233
00234 ClassDef(TGeoIteratorPlugin, 0)
00235 };
00236
00237
00238
00239
00240
00241
00242
00243 class TGeoIterator
00244 {
00245 private:
00246 TGeoVolume *fTop;
00247 Bool_t fMustResume;
00248 Bool_t fMustStop;
00249 Int_t fLevel;
00250 Int_t fType;
00251 Int_t *fArray;
00252 TGeoHMatrix *fMatrix;
00253 TString fTopName;
00254 TGeoIteratorPlugin
00255 *fPlugin;
00256 Bool_t fPluginAutoexec;
00257
00258 void IncreaseArray();
00259 protected:
00260 TGeoIterator() : fTop(0), fMustResume(0), fMustStop(0), fLevel(0), fType(0),
00261 fArray(0), fMatrix(0), fTopName(), fPlugin(0), fPluginAutoexec(kFALSE) { }
00262
00263 public:
00264 TGeoIterator(TGeoVolume *top);
00265 TGeoIterator(const TGeoIterator &iter);
00266 virtual ~TGeoIterator();
00267
00268 TGeoIterator &operator=(const TGeoIterator &iter);
00269 TGeoNode *operator()();
00270 TGeoNode *Next();
00271
00272 const TGeoMatrix *GetCurrentMatrix() const;
00273 Int_t GetIndex(Int_t i) const {return ((i<=fLevel)?fArray[i]:-1);}
00274 Int_t GetLevel() const {return fLevel;}
00275 TGeoNode *GetNode(Int_t level) const;
00276 void GetPath(TString &path) const;
00277 TGeoIteratorPlugin
00278 *GetUserPlugin() const {return fPlugin;}
00279
00280 TGeoVolume *GetTopVolume() const {return fTop;}
00281 Int_t GetType() const {return fType;}
00282 void Reset(TGeoVolume *top=0);
00283 void SetUserPlugin(TGeoIteratorPlugin *plugin);
00284 void SetPluginAutoexec(Bool_t mode) {fPluginAutoexec = mode;}
00285 void SetType(Int_t type) {fType = type;}
00286 void SetTopName(const char* name);
00287 void Skip();
00288
00289 ClassDef(TGeoIterator,0)
00290 };
00291
00292 #endif