13 #ifndef ROOT_TGeoVolume
14 #define ROOT_TGeoVolume
30 class TGeoPatternFinder;
31 class TGeoVoxelFinder;
42 class TGeoVolume :
public TNamed,
52 static TGeoMedium *fgDummyMedium;
53 TGeoPatternFinder *fFinder;
54 TGeoVoxelFinder *fVoxels;
55 TGeoManager *fGeoManager;
62 TGeoExtension *fUserExtension;
63 TGeoExtension *fFWExtension;
66 TGeoVolume(
const TGeoVolume&);
67 TGeoVolume& operator=(
const TGeoVolume&);
70 virtual void ClearThreadData()
const;
71 virtual void CreateThreadData(Int_t nthreads);
74 enum EGeoVolumeTypes {
75 kVolumeReplicated = BIT(14),
76 kVolumeSelected = BIT(15),
78 kVolumeOverlap = BIT(17),
79 kVolumeImportNodes = BIT(18),
80 kVolumeMulti = BIT(19),
83 kVolumeClone = BIT(22),
84 kVolumeAdded = BIT(23),
89 TGeoVolume(
const char *name,
const TGeoShape *shape,
const TGeoMedium *med=0);
92 virtual ~TGeoVolume();
94 virtual void cd(Int_t inode)
const;
95 void Browse(TBrowser *b);
96 Double_t Capacity()
const;
98 void ClearNodes() {fNodes = 0;}
101 virtual TGeoVolume *CloneVolume()
const;
102 void CloneNodesAndConnect(TGeoVolume *newmother)
const;
103 void CheckGeometry(Int_t nrays=1, Double_t startx=0, Double_t starty=0, Double_t startz=0)
const;
104 void CheckOverlaps(Double_t ovlp=0.1, Option_t *option=
"")
const;
105 void CheckShape(Int_t testNo, Int_t nsamples=10000, Option_t *option=
"");
106 Int_t CountNodes(Int_t nlevels=1000, Int_t option=0);
107 Bool_t Contains(
const Double_t *point)
const {
return fShape->Contains(point);}
108 static void CreateDummyMedium();
109 static TGeoMedium *DummyMedium();
110 virtual Bool_t IsAssembly()
const;
111 virtual Bool_t IsFolder()
const;
112 Bool_t IsRunTime()
const {
return fShape->IsRunTimeShape();}
113 virtual Bool_t IsVolumeMulti()
const {
return kFALSE;}
114 virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option=
"");
115 void AddNodeOffset(TGeoVolume *vol, Int_t copy_no, Double_t offset=0, Option_t *option=
"");
116 virtual void AddNodeOverlap(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option=
"");
118 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=
"");
119 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
120 virtual void Draw(Option_t *option=
"");
121 virtual void DrawOnly(Option_t *option=
"");
122 TH2F *LegoPlot(Int_t ntheta=20, Double_t themin=0., Double_t themax=180.,
123 Int_t nphi=60, Double_t phimin=0., Double_t phimax=360.,
124 Double_t rmin=0., Double_t rmax=9999999, Option_t *option=
"");
125 virtual void Paint(Option_t *option=
"");
126 virtual void Print(Option_t *option=
"")
const;
127 void PrintNodes()
const;
128 void PrintVoxels()
const;
129 void ReplayCreation(
const TGeoVolume *other);
130 void SetUserExtension(TGeoExtension *ext);
131 void SetFWExtension(TGeoExtension *ext);
132 Int_t GetRefCount()
const {
return fRefCount;}
133 TGeoExtension *GetUserExtension()
const {
return fUserExtension;}
134 TGeoExtension *GetFWExtension()
const {
return fFWExtension;}
135 TGeoExtension *GrabUserExtension()
const;
136 TGeoExtension *GrabFWExtension()
const;
137 void Grab() {fRefCount++;}
138 void Release() {fRefCount--;
if (fRefCount==0)
delete this;}
139 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
141 Bool_t IsActive()
const {
return TGeoAtt::IsActive();}
142 Bool_t IsActiveDaughters()
const {
return TGeoAtt::IsActiveDaughters();}
143 Bool_t IsAdded()
const {
return TObject::TestBit(kVolumeAdded);}
144 Bool_t IsOverlappingCandidate()
const {
return TObject::TestBit(kVolumeOC);}
145 Bool_t IsReplicated()
const {
return TObject::TestBit(kVolumeReplicated);}
146 Bool_t IsSelected()
const {
return TObject::TestBit(kVolumeSelected);}
147 Bool_t IsCylVoxels()
const {
return TObject::TestBit(kVoxelsCyl);}
148 Bool_t IsXYZVoxels()
const {
return TObject::TestBit(kVoxelsXYZ);}
149 Bool_t IsTopVolume()
const;
150 Bool_t IsValid()
const {
return fShape->IsValid();}
151 virtual Bool_t IsVisible()
const {
return TGeoAtt::IsVisible();}
152 Bool_t IsVisibleDaughters()
const {
return TGeoAtt::IsVisDaughters();}
153 Bool_t IsVisContainers()
const {
return TGeoAtt::IsVisContainers();}
154 Bool_t IsVisLeaves()
const {
return TGeoAtt::IsVisLeaves();}
155 Bool_t IsVisOnly()
const {
return TGeoAtt::IsVisOnly();}
156 Bool_t IsAllInvisible()
const;
157 Bool_t IsRaytracing()
const;
158 static TGeoVolume *Import(
const char *filename,
const char *name=
"", Option_t *option=
"");
159 Int_t Export(
const char *filename,
const char *name=
"", Option_t *option=
"");
160 TGeoNode *FindNode(
const char *name)
const;
161 void FindOverlaps()
const;
162 Bool_t FindMatrixOfDaughterVolume(TGeoVolume *vol)
const;
163 virtual Int_t GetCurrentNodeIndex()
const {
return -1;}
164 virtual Int_t GetNextNodeIndex()
const {
return -1;}
165 TObjArray *GetNodes() {
return fNodes;}
166 Int_t GetNdaughters()
const;
167 Int_t GetNtotal()
const {
return fNtotal;}
168 virtual Int_t GetByteCount()
const;
169 TGeoManager *GetGeoManager()
const {
return fGeoManager;}
170 TGeoMaterial *GetMaterial()
const {
return GetMedium()->GetMaterial();}
171 TGeoMedium *GetMedium()
const {
return (fMedium)?fMedium:DummyMedium();}
172 TObject *GetField()
const {
return fField;}
173 TGeoPatternFinder *GetFinder()
const {
return fFinder;}
174 TGeoVoxelFinder *GetVoxels()
const;
175 const char *GetIconName()
const {
return fShape->GetName();}
176 Int_t GetIndex(
const TGeoNode *node)
const;
177 TGeoNode *GetNode(
const char *name)
const;
178 TGeoNode *GetNode(Int_t i)
const {
return (TGeoNode*)fNodes->UncheckedAt(i);}
179 Int_t GetNodeIndex(
const TGeoNode *node, Int_t *check_list, Int_t ncheck)
const;
180 Int_t GetNumber()
const {
return fNumber;}
181 virtual char *GetObjectInfo(Int_t px, Int_t py)
const;
182 Bool_t GetOptimalVoxels()
const;
183 Option_t *GetOption()
const {
return fOption.Data(); }
184 char *GetPointerName()
const;
185 Char_t GetTransparency()
const {
return (fMedium==0)?0:(fMedium->GetMaterial()->GetTransparency());}
186 TGeoShape *GetShape()
const {
return fShape;}
188 void Gsord(Int_t ) {;}
189 Bool_t IsStyleDefault()
const;
190 void InspectMaterial()
const;
191 void InspectShape()
const {fShape->InspectShape();}
192 virtual TGeoVolume *MakeCopyVolume(TGeoShape *newshape);
193 void MakeCopyNodes(
const TGeoVolume *other);
194 TGeoVolume *MakeReflectedVolume(
const char *newname=
"")
const;
195 Bool_t OptimizeVoxels();
196 void RandomPoints(Int_t npoints=1000000, Option_t *option=
"");
197 void RandomRays(Int_t nrays=10000, Double_t startx=0, Double_t starty=0, Double_t startz=0,
const char *target_vol=0, Bool_t check_norm=kFALSE);
198 void Raytrace(Bool_t flag=kTRUE);
199 void RegisterYourself(Option_t *option=
"");
200 void RemoveNode(TGeoNode *node);
201 TGeoNode *ReplaceNode(TGeoNode *nodeorig, TGeoShape *newshape=0, TGeoMatrix *newpos=0, TGeoMedium *newmed=0);
202 void SaveAs(
const char *filename,Option_t *option=
"")
const;
203 virtual void SavePrimitive(std::ostream &out, Option_t *option =
"");
204 void SelectVolume(Bool_t clear = kFALSE);
205 void SetActivity(Bool_t flag=kTRUE) {TGeoAtt::SetActivity(flag);}
206 void SetActiveDaughters(Bool_t flag=kTRUE) {TGeoAtt::SetActiveDaughters(flag);}
207 void SetAsTopVolume();
208 void SetAdded() {TObject::SetBit(kVolumeAdded);}
209 void SetReplicated() {TObject::SetBit(kVolumeReplicated);}
210 void SetCurrentPoint(Double_t x, Double_t y, Double_t z);
211 void SetCylVoxels(Bool_t flag=kTRUE) {TObject::SetBit(kVoxelsCyl, flag); TObject::SetBit(kVoxelsXYZ, !flag);}
212 void SetNodes(TObjArray *nodes) {fNodes = nodes; TObject::SetBit(kVolumeImportNodes);}
213 void SetOverlappingCandidate(Bool_t flag) {TObject::SetBit(kVolumeOC,flag);}
214 void SetShape(
const TGeoShape *shape);
215 void SetTransparency(Char_t transparency=0) {
if (fMedium) fMedium->GetMaterial()->SetTransparency(transparency);}
216 void SetField(TObject *field) {fField = field;}
217 void SetOption(
const char *option);
218 void SetAttVisibility(Bool_t vis) {TGeoAtt::SetVisibility(vis);}
219 virtual void SetVisibility(Bool_t vis=kTRUE);
220 virtual void SetVisContainers(Bool_t flag=kTRUE);
221 virtual void SetVisLeaves(Bool_t flag=kTRUE);
222 virtual void SetVisOnly(Bool_t flag=kTRUE);
223 virtual void SetLineColor(Color_t lcolor);
224 virtual void SetLineStyle(Style_t lstyle);
225 virtual void SetLineWidth(Width_t lwidth);
226 void SetInvisible() {SetVisibility(kFALSE);}
227 virtual void SetMedium(TGeoMedium *medium) {fMedium = medium;}
228 void SetVoxelFinder(TGeoVoxelFinder *finder) {fVoxels = finder;}
229 void SetFinder(TGeoPatternFinder *finder) {fFinder = finder;}
230 void SetNumber(Int_t number) {fNumber = number;}
231 void SetNtotal(Int_t ntotal) {fNtotal = ntotal;}
234 Bool_t Valid()
const;
235 void VisibleDaughters(Bool_t vis=kTRUE);
236 void InvisibleAll(Bool_t flag=kTRUE);
237 void Voxelize(Option_t *option);
238 Double_t Weight(Double_t precision=0.01, Option_t *option=
"va");
239 Double_t WeightA()
const;
241 ClassDef(TGeoVolume, 6)
251 class TGeoVolumeMulti :
public TGeoVolume
255 TGeoVolumeMulti *fDivision;
263 TGeoVolumeMulti(
const TGeoVolumeMulti&);
264 TGeoVolumeMulti& operator=(
const TGeoVolumeMulti&);
268 TGeoVolumeMulti(
const char* name, TGeoMedium *med=0);
269 virtual ~TGeoVolumeMulti();
271 void AddVolume(TGeoVolume *vol);
272 TGeoVolume *GetVolume(Int_t
id)
const {
return (TGeoVolume*)fVolumes->At(
id);}
273 virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t *option=
"");
274 virtual void AddNodeOverlap(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t *option=
"");
275 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=
"");
276 TGeoShape *GetLastShape()
const;
277 Int_t GetNvolumes()
const {
return fVolumes->GetEntriesFast();}
278 Int_t GetAxis()
const {
return fNdiv;}
279 Int_t GetNdiv()
const {
return fNdiv;}
280 Double_t GetStart()
const {
return fStart;}
281 Double_t GetStep()
const {
return fStep;}
282 virtual Bool_t IsVolumeMulti()
const {
return kTRUE;}
283 virtual TGeoVolume *MakeCopyVolume(TGeoShape *newshape);
284 virtual void SetLineColor(Color_t lcolor);
285 virtual void SetLineStyle(Style_t lstyle);
286 virtual void SetLineWidth(Width_t lwidth);
287 virtual void SetMedium(TGeoMedium *medium);
288 virtual void SetVisibility(Bool_t vis=kTRUE);
290 ClassDef(TGeoVolumeMulti, 3)
300 class TGeoVolumeAssembly :
public TGeoVolume
312 ThreadData_t& GetThreadData()
const;
313 virtual void ClearThreadData()
const;
314 virtual void CreateThreadData(Int_t nthreads);
317 mutable std::vector<ThreadData_t*> fThreadData;
318 mutable Int_t fThreadSize;
319 mutable std::mutex fMutex;
322 TGeoVolumeAssembly(
const TGeoVolumeAssembly &);
323 TGeoVolumeAssembly& operator=(
const TGeoVolumeAssembly&);
326 TGeoVolumeAssembly();
327 TGeoVolumeAssembly(
const char *name);
328 virtual ~TGeoVolumeAssembly();
330 virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option=
"");
331 virtual void AddNodeOverlap(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat, Option_t *option);
332 virtual TGeoVolume *CloneVolume()
const;
333 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=
"");
334 TGeoVolume *Divide(TGeoVolume *cell, TGeoPatternFinder *pattern, Option_t *option=
"spacedout");
335 virtual void DrawOnly(Option_t *) {;}
336 virtual Int_t GetCurrentNodeIndex()
const;
337 virtual Int_t GetNextNodeIndex()
const;
338 virtual Bool_t IsAssembly()
const {
return kTRUE;}
339 virtual Bool_t IsVisible()
const {
return kFALSE;}
340 static TGeoVolumeAssembly *MakeAssemblyFromVolume(TGeoVolume *vol);
341 void SetCurrentNodeIndex(Int_t index);
342 void SetNextNodeIndex(Int_t index);
344 ClassDef(TGeoVolumeAssembly, 2)
347 inline Int_t TGeoVolume::GetNdaughters()
const {
if (!fNodes)
return 0;
return (fNodes->GetEntriesFast());}