00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ROOT_TGeoVolume
00014 #define ROOT_TGeoVolume
00015
00016
00017 #ifndef ROOT_TGeoAtt
00018 #include "TGeoAtt.h"
00019 #endif
00020
00021 #ifndef ROOT_TAttLine
00022 #include "TAttLine.h"
00023 #endif
00024
00025 #ifndef ROOT_TAttFill
00026 #include "TAttFill.h"
00027 #endif
00028
00029 #ifndef ROOT_TAtt3D
00030 #include "TAtt3D.h"
00031 #endif
00032
00033 #ifndef ROOT_TObjArray
00034 #include "TObjArray.h"
00035 #endif
00036
00037 #ifndef ROOT_TGeoMedium
00038 #include "TGeoMedium.h"
00039 #endif
00040
00041 #ifndef ROOT_TGeoShape
00042 #include "TGeoShape.h"
00043 #endif
00044
00045
00046 class TH2F;
00047 class TGeoNode;
00048 class TGeoMatrix;
00049 class TGeoPatternFinder;
00050 class TGeoVoxelFinder;
00051 class TGeoManager;
00052
00053
00054
00055
00056
00057
00058
00059
00060 class TGeoVolume : public TNamed,
00061 public TGeoAtt,
00062 public TAttLine,
00063 public TAttFill,
00064 public TAtt3D
00065 {
00066 protected :
00067 TObjArray *fNodes;
00068 TGeoShape *fShape;
00069 TGeoMedium *fMedium;
00070 TGeoPatternFinder *fFinder;
00071 TGeoVoxelFinder *fVoxels;
00072 TGeoManager *fGeoManager;
00073
00074 TObject *fField;
00075 TString fOption;
00076 Int_t fNumber;
00077 Int_t fNtotal;
00078
00079 TGeoVolume(const TGeoVolume&);
00080 TGeoVolume& operator=(const TGeoVolume&);
00081
00082 public:
00083 enum EGeoVolumeTypes {
00084 kVolumeReplicated = BIT(14),
00085 kVolumeSelected = BIT(15),
00086 kVolumeDiv = BIT(16),
00087 kVolumeOverlap = BIT(17),
00088 kVolumeImportNodes = BIT(18),
00089 kVolumeMulti = BIT(19),
00090 kVoxelsXYZ = BIT(20),
00091 kVoxelsCyl = BIT(21),
00092 kVolumeClone = BIT(22),
00093 kVolumeAdded = BIT(23)
00094 };
00095
00096 TGeoVolume();
00097 TGeoVolume(const char *name, const TGeoShape *shape, const TGeoMedium *med=0);
00098
00099
00100 virtual ~TGeoVolume();
00101
00102 virtual void cd(Int_t inode) const;
00103 void Browse(TBrowser *b);
00104 Double_t Capacity() const;
00105 void CheckShapes();
00106 void ClearNodes() {fNodes = 0;}
00107 void ClearShape();
00108 void CleanAll();
00109 virtual TGeoVolume *CloneVolume() const;
00110 void CloneNodesAndConnect(TGeoVolume *newmother) const;
00111 void CheckGeometry(Int_t nrays=1, Double_t startx=0, Double_t starty=0, Double_t startz=0) const;
00112 void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="") const;
00113 Int_t CountNodes(Int_t nlevels=1000, Int_t option=0);
00114 Bool_t Contains(Double_t *point) const {return fShape->Contains(point);}
00115 virtual Bool_t IsAssembly() const {return kFALSE;}
00116 virtual Bool_t IsFolder() const;
00117 Bool_t IsRunTime() const {return fShape->IsRunTimeShape();}
00118 virtual Bool_t IsVolumeMulti() const {return kFALSE;}
00119 virtual void AddNode(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="");
00120 void AddNodeOffset(const TGeoVolume *vol, Int_t copy_no, Double_t offset=0, Option_t *option="");
00121 virtual void AddNodeOverlap(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="");
00122
00123 virtual TGeoVolume *Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="");
00124 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
00125 virtual void Draw(Option_t *option="");
00126 virtual void DrawOnly(Option_t *option="");
00127 TH2F *LegoPlot(Int_t ntheta=20, Double_t themin=0., Double_t themax=180.,
00128 Int_t nphi=60, Double_t phimin=0., Double_t phimax=360.,
00129 Double_t rmin=0., Double_t rmax=9999999, Option_t *option="");
00130 virtual void Paint(Option_t *option="");
00131 void PrintNodes() const;
00132 void PrintVoxels() const;
00133 void ReplayCreation(const TGeoVolume *other);
00134 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
00135
00136 Bool_t IsActive() const {return TGeoAtt::IsActive();}
00137 Bool_t IsActiveDaughters() const {return TGeoAtt::IsActiveDaughters();}
00138 Bool_t IsAdded() const {return TObject::TestBit(kVolumeAdded);}
00139 Bool_t IsReplicated() const {return TObject::TestBit(kVolumeReplicated);}
00140 Bool_t IsSelected() const {return TObject::TestBit(kVolumeSelected);}
00141 Bool_t IsCylVoxels() const {return TObject::TestBit(kVoxelsCyl);}
00142 Bool_t IsXYZVoxels() const {return TObject::TestBit(kVoxelsXYZ);}
00143 Bool_t IsTopVolume() const;
00144 Bool_t IsValid() const {return fShape->IsValid();}
00145 virtual Bool_t IsVisible() const {return TGeoAtt::IsVisible();}
00146 Bool_t IsVisibleDaughters() const {return TGeoAtt::IsVisDaughters();}
00147 Bool_t IsVisContainers() const {return TGeoAtt::IsVisContainers();}
00148 Bool_t IsVisLeaves() const {return TGeoAtt::IsVisLeaves();}
00149 Bool_t IsVisOnly() const {return TGeoAtt::IsVisOnly();}
00150 Bool_t IsAllInvisible() const;
00151 Bool_t IsRaytracing() const;
00152 static TGeoVolume *Import(const char *filename, const char *name="", Option_t *option="");
00153 Int_t Export(const char *filename, const char *name="", Option_t *option="");
00154 TGeoNode *FindNode(const char *name) const;
00155 void FindOverlaps() const;
00156 Bool_t FindMatrixOfDaughterVolume(TGeoVolume *vol) const;
00157 virtual Int_t GetCurrentNodeIndex() const {return -1;}
00158 virtual Int_t GetNextNodeIndex() const {return -1;}
00159 TObjArray *GetNodes() {return fNodes;}
00160 Int_t GetNdaughters() const;
00161 Int_t GetNtotal() const {return fNtotal;}
00162 virtual Int_t GetByteCount() const;
00163 TGeoManager *GetGeoManager() const {return fGeoManager;}
00164 TGeoMaterial *GetMaterial() const {return fMedium->GetMaterial();}
00165 TGeoMedium *GetMedium() const {return fMedium;}
00166 TObject *GetField() const {return fField;}
00167 TGeoPatternFinder *GetFinder() const {return fFinder;}
00168 TGeoVoxelFinder *GetVoxels() const;
00169 const char *GetIconName() const {return fShape->GetName();}
00170 Int_t GetIndex(const TGeoNode *node) const;
00171 TGeoNode *GetNode(const char *name) const;
00172 TGeoNode *GetNode(Int_t i) const {return (TGeoNode*)fNodes->UncheckedAt(i);}
00173 Int_t GetNodeIndex(const TGeoNode *node, Int_t *check_list, Int_t ncheck) const;
00174 Int_t GetNumber() const {return fNumber;}
00175 virtual char *GetObjectInfo(Int_t px, Int_t py) const;
00176 Bool_t GetOptimalVoxels() const;
00177 Option_t *GetOption() const { return fOption.Data(); }
00178 char *GetPointerName() const;
00179 Char_t GetTransparency() const {return (fMedium==0)?0:(fMedium->GetMaterial()->GetTransparency());}
00180 TGeoShape *GetShape() const {return fShape;}
00181 void GrabFocus();
00182 void Gsord(Int_t ) {;}
00183 Bool_t IsStyleDefault() const;
00184 void InspectMaterial() const;
00185 void InspectShape() const {fShape->InspectShape();}
00186 virtual TGeoVolume *MakeCopyVolume(TGeoShape *newshape);
00187 void MakeCopyNodes(const TGeoVolume *other);
00188 TGeoVolume *MakeReflectedVolume(const char *newname="") const;
00189 Bool_t OptimizeVoxels();
00190 void RandomPoints(Int_t npoints=1000000, Option_t *option="");
00191 void RandomRays(Int_t nrays=10000, Double_t startx=0, Double_t starty=0, Double_t startz=0);
00192 void Raytrace(Bool_t flag=kTRUE);
00193 void RegisterYourself(Option_t *option="");
00194 void RemoveNode(TGeoNode *node);
00195 TGeoNode *ReplaceNode(TGeoNode *nodeorig, TGeoShape *newshape=0, TGeoMatrix *newpos=0, TGeoMedium *newmed=0);
00196 void SaveAs(const char *filename,Option_t *option="") const;
00197 virtual void SavePrimitive(ostream &out, Option_t *option = "");
00198 void SelectVolume(Bool_t clear = kFALSE);
00199 void SetActivity(Bool_t flag=kTRUE) {TGeoAtt::SetActivity(flag);}
00200 void SetActiveDaughters(Bool_t flag=kTRUE) {TGeoAtt::SetActiveDaughters(flag);}
00201 void SetAsTopVolume();
00202 void SetAdded() {TObject::SetBit(kVolumeAdded);}
00203 void SetReplicated() {TObject::SetBit(kVolumeReplicated);}
00204 void SetCurrentPoint(Double_t x, Double_t y, Double_t z);
00205 void SetCylVoxels(Bool_t flag=kTRUE) {TObject::SetBit(kVoxelsCyl, flag); TObject::SetBit(kVoxelsXYZ, !flag);}
00206 void SetNodes(TObjArray *nodes) {fNodes = nodes; TObject::SetBit(kVolumeImportNodes);}
00207 void SetShape(const TGeoShape *shape);
00208 void SetTransparency(Char_t transparency=0) {if (fMedium) fMedium->GetMaterial()->SetTransparency(transparency);}
00209 void SetField(TObject *field) {fField = field;}
00210 void SetOption(const char *option);
00211 void SetAttVisibility(Bool_t vis) {TGeoAtt::SetVisibility(vis);}
00212 virtual void SetVisibility(Bool_t vis=kTRUE);
00213 virtual void SetVisContainers(Bool_t flag=kTRUE);
00214 virtual void SetVisLeaves(Bool_t flag=kTRUE);
00215 virtual void SetVisOnly(Bool_t flag=kTRUE);
00216 virtual void SetLineColor(Color_t lcolor);
00217 virtual void SetLineStyle(Style_t lstyle);
00218 virtual void SetLineWidth(Width_t lwidth);
00219 void SetInvisible() {SetVisibility(kFALSE);}
00220 virtual void SetMedium(TGeoMedium *medium) {fMedium = medium;}
00221 void SetVoxelFinder(TGeoVoxelFinder *finder) {fVoxels = finder;}
00222 void SetFinder(TGeoPatternFinder *finder) {fFinder = finder;}
00223 void SetNumber(Int_t number) {fNumber = number;}
00224 void SetNtotal(Int_t ntotal) {fNtotal = ntotal;}
00225 void SortNodes();
00226 void UnmarkSaved();
00227 Bool_t Valid() const;
00228 void VisibleDaughters(Bool_t vis=kTRUE);
00229 void InvisibleAll(Bool_t flag=kTRUE);
00230 void Voxelize(Option_t *option);
00231 Double_t Weight(Double_t precision=0.01, Option_t *option="va");
00232 Double_t WeightA() const;
00233
00234 ClassDef(TGeoVolume, 5)
00235 };
00236
00237
00238
00239
00240
00241
00242
00243
00244 class TGeoVolumeMulti : public TGeoVolume
00245 {
00246 private:
00247 TObjArray *fVolumes;
00248 TGeoVolumeMulti *fDivision;
00249 Int_t fNumed;
00250 Int_t fNdiv;
00251 Int_t fAxis;
00252 Double_t fStart;
00253 Double_t fStep;
00254 Bool_t fAttSet;
00255
00256 protected:
00257 TGeoVolumeMulti(const TGeoVolumeMulti&);
00258 TGeoVolumeMulti& operator=(const TGeoVolumeMulti&);
00259
00260 public:
00261 TGeoVolumeMulti();
00262 TGeoVolumeMulti(const char* name, TGeoMedium *med=0);
00263 virtual ~TGeoVolumeMulti();
00264
00265 void AddVolume(TGeoVolume *vol);
00266 TGeoVolume *GetVolume(Int_t id) const {return (TGeoVolume*)fVolumes->At(id);}
00267 virtual void AddNode(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t *option="");
00268 virtual void AddNodeOverlap(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t *option="");
00269 virtual TGeoVolume *Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="");
00270 TGeoShape *GetLastShape() const {return GetVolume(fVolumes->GetEntriesFast()-1)->GetShape();}
00271 Int_t GetNvolumes() const {return fVolumes->GetEntriesFast();}
00272 Int_t GetAxis() const {return fNdiv;}
00273 Int_t GetNdiv() const {return fNdiv;}
00274 Double_t GetStart() const {return fStart;}
00275 Double_t GetStep() const {return fStep;}
00276 virtual Bool_t IsVolumeMulti() const {return kTRUE;}
00277 virtual TGeoVolume *MakeCopyVolume(TGeoShape *newshape);
00278 virtual void SetLineColor(Color_t lcolor);
00279 virtual void SetLineStyle(Style_t lstyle);
00280 virtual void SetLineWidth(Width_t lwidth);
00281 virtual void SetMedium(TGeoMedium *medium);
00282 virtual void SetVisibility(Bool_t vis=kTRUE);
00283
00284
00285 ClassDef(TGeoVolumeMulti, 3)
00286 };
00287
00288
00289
00290
00291
00292
00293
00294
00295 class TGeoVolumeAssembly : public TGeoVolume
00296 {
00297 private:
00298 Int_t fCurrent;
00299 Int_t fNext;
00300 public:
00301 TGeoVolumeAssembly();
00302 TGeoVolumeAssembly(const char *name);
00303 virtual ~TGeoVolumeAssembly();
00304
00305 virtual void AddNode(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="");
00306 virtual void AddNodeOverlap(const TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t *option);
00307 virtual TGeoVolume *CloneVolume() const;
00308 virtual TGeoVolume *Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="");
00309 virtual void DrawOnly(Option_t *) {;}
00310 virtual Int_t GetCurrentNodeIndex() const {return fCurrent;}
00311 virtual Int_t GetNextNodeIndex() const {return fNext;}
00312 virtual Bool_t IsAssembly() const {return kTRUE;}
00313 virtual Bool_t IsVisible() const {return kFALSE;}
00314 static TGeoVolumeAssembly *MakeAssemblyFromVolume(TGeoVolume *vol);
00315 void SetCurrentNodeIndex(Int_t index) {fCurrent = index;}
00316 void SetNextNodeIndex(Int_t index) {fNext = index;}
00317
00318 ClassDef(TGeoVolumeAssembly, 2)
00319 };
00320
00321 inline Int_t TGeoVolume::GetNdaughters() const {if (!fNodes) return 0; return (fNodes->GetEntriesFast());}
00322
00323 #endif
00324