Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoManager.cxx
Go to the documentation of this file.
1// @(#)root/geom:$Id$
2// Author: Andrei Gheata 25/10/01
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TGeoManager
13\ingroup Geometry_classes
14
15The manager class for any TGeo geometry. Provides user
16interface for geometry creation, navigation, state querying,
17visualization, IO, geometry checking and other utilities.
18
19## General architecture
20
21 The ROOT geometry package is a tool designed for building, browsing,
22tracking and visualizing a detector geometry. The code is independent from
23other external MC for simulation, therefore it does not contain any
24constraints related to physics. However, the package defines a number of
25hooks for tracking, such as media, materials, magnetic field or track state flags,
26in order to allow interfacing to tracking MC's. The final goal is to be
27able to use the same geometry for several purposes, such as tracking,
28reconstruction or visualization, taking advantage of the ROOT features
29related to bookkeeping, I/O, histogramming, browsing and GUI's.
30
31 The geometrical modeler is the most important component of the package and
32it provides answers to the basic questions like "Where am I ?" or "How far
33from the next boundary ?", but also to more complex ones like "How far from
34the closest surface ?" or "Which is the next crossing along a helix ?".
35
36 The architecture of the modeler is a combination between a GEANT-like
37containment scheme and a normal CSG binary tree at the level of shapes. An
38important common feature of all detector geometry descriptions is the
39mother-daughter concept. This is the most natural approach when tracking
40is concerned and imposes a set of constraints to the way geometry is defined.
41Constructive solid geometry composition is used only in order to create more
42complex shapes from an existing set of primitives through boolean operations.
43This feature is not implemented yet but in future full definition of boolean
44expressions will be supported.
45
46 Practically every geometry defined in GEANT style can be mapped by the modeler.
47The basic components used for building the logical hierarchy of the geometry
48are called "volumes" and "nodes". Volumes (sometimes called "solids") are fully
49defined geometrical objects having a given shape and medium and possibly
50containing a list of nodes. Nodes represent just positioned instances of volumes
51inside a container volume and they are not directly defined by user. They are
52automatically created as a result of adding one volume inside other or dividing
53a volume. The geometrical transformation hold by nodes is always defined with
54respect to their mother (relative positioning). Reflection matrices are allowed.
55All volumes have to be fully aware of their containees when the geometry is
56closed. They will build additional structures (voxels) in order to fasten-up
57the search algorithms. Finally, nodes can be regarded as bidirectional links
58between containers and containees objects.
59
60 The structure defined in this way is a graph structure since volumes are
61replicable (same volume can become daughter node of several other volumes),
62every volume becoming a branch in this graph. Any volume in the logical graph
63can become the actual top volume at run time (see TGeoManager::SetTopVolume()).
64All functionalities of the modeler will behave in this case as if only the
65corresponding branch starting from this volume is the registered geometry.
66
67\image html geom_graf.jpg
68
69 A given volume can be positioned several times in the geometry. A volume
70can be divided according default or user-defined patterns, creating automatically
71the list of division nodes inside. The elementary volumes created during the
72dividing process follow the same scheme as usual volumes, therefore it is possible
73to position further geometrical structures inside or to divide them further more
74(see TGeoVolume::Divide()).
75
76 The primitive shapes supported by the package are basically the GEANT3
77shapes (see class TGeoShape), arbitrary wedges with eight vertices on two parallel
78planes. All basic primitives inherits from class TGeoBBox since the bounding box
79of a solid is essential for the tracking algorithms. They also implement the
80virtual methods defined in the virtual class TGeoShape (point and segment
81classification). User-defined primitives can be directly plugged into the modeler
82provided that they override these methods. Composite shapes will be soon supported
83by the modeler. In order to build a TGeoCompositeShape, one will have to define
84first the primitive components. The object that handle boolean
85operations among components is called TGeoBoolCombinator and it has to be
86constructed providing a string boolean expression between the components names.
87
88
89## Example for building a simple geometry
90
91Begin_Macro(source)
92../../../tutorials/visualisation/geom/rootgeom.C
93End_Macro
94
95## TGeoManager - the manager class for the geometry package.
96
97 TGeoManager class is embedding all the API needed for building and tracking
98a geometry. It defines a global pointer (gGeoManager) in order to be fully
99accessible from external code. The mechanism of handling multiple geometries
100at the same time will be soon implemented.
101
102 TGeoManager is the owner of all geometry objects defined in a session,
103therefore users must not try to control their deletion. It contains lists of
104media, materials, transformations, shapes and volumes. Logical nodes (positioned
105volumes) are created and destroyed by the TGeoVolume class. Physical
106nodes and their global transformations are subjected to a caching mechanism
107due to the sometimes very large memory requirements of logical graph expansion.
108The caching mechanism is triggered by the total number of physical instances
109of volumes and the cache manager is a client of TGeoManager. The manager class
110also controls the painter client. This is linked with ROOT graphical libraries
111loaded on demand in order to control visualization actions.
112
113## Rules for building a valid geometry
114
115 A given geometry can be built in various ways, but there are mandatory steps
116that have to be followed in order to be validated by the modeler. There are
117general rules : volumes needs media and shapes in order to be created,
118both container and containee volumes must be created before linking them together,
119and the relative transformation matrix must be provided. All branches must
120have an upper link point otherwise they will not be considered as part of the
121geometry. Visibility or tracking properties of volumes can be provided both
122at build time or after geometry is closed, but global visualization settings
123(see TGeoPainter class) should not be provided at build time, otherwise the
124drawing package will be loaded. There is also a list of specific rules :
125positioned daughters should not extrude their mother or intersect with sisters
126unless this is specified (see TGeoVolume::AddNodeOverlap()), the top volume
127(containing all geometry tree) must be specified before closing the geometry
128and must not be positioned - it represents the global reference frame. After
129building the full geometry tree, the geometry must be closed
130(see TGeoManager::CloseGeometry()). Voxelization can be redone per volume after
131this process.
132
133
134 Below is the general scheme of the manager class.
135
136\image html geom_mgr.jpg
137
138## An interactive session
139
140 Provided that a geometry was successfully built and closed (for instance the
141previous example rootgeom.C ), the manager class will register
142itself to ROOT and the logical/physical structures will become immediately browsable.
143The ROOT browser will display starting from the geometry folder : the list of
144transformations and media, the top volume and the top logical node. These last
145two can be fully expanded, any intermediate volume/node in the browser being subject
146of direct access context menu operations (right mouse button click). All user
147utilities of classes TGeoManager, TGeoVolume and TGeoNode can be called via the
148context menu.
149
150\image html geom_browser.jpg
151
152### Drawing the geometry
153
154 Any logical volume can be drawn via TGeoVolume::Draw() member function.
155This can be directly accessed from the context menu of the volume object
156directly from the browser.
157 There are several drawing options that can be set with
158TGeoManager::SetVisOption(Int_t opt) method :
159
160#### opt=0
161 only the content of the volume is drawn, N levels down (default N=3).
162 This is the default behavior. The number of levels to be drawn can be changed
163 via TGeoManager::SetVisLevel(Int_t level) method.
164
165\image html geom_frame0.jpg
166
167#### opt=1
168 the final leaves (e.g. daughters with no containment) of the branch
169 starting from volume are drawn down to the current number of levels.
170 WARNING : This mode is memory consuming
171 depending of the size of geometry, so drawing from top level within this mode
172 should be handled with care for expensive geometries. In future there will be
173 a limitation on the maximum number of nodes to be visualized.
174
175\image html geom_frame1.jpg
176
177#### opt=2
178 only the clicked volume is visualized. This is automatically set by
179 TGeoVolume::DrawOnly() method
180
181#### opt=3 - only a given path is visualized. This is automatically set by
182 TGeoVolume::DrawPath(const char *path) method
183
184 The current view can be exploded in cartesian, cylindrical or spherical
185coordinates :
186 TGeoManager::SetExplodedView(Int_t opt). Options may be :
187- 0 - default (no bombing)
188- 1 - cartesian coordinates. The bomb factor on each axis can be set with
189 TGeoManager::SetBombX(Double_t bomb) and corresponding Y and Z.
190- 2 - bomb in cylindrical coordinates. Only the bomb factors on Z and R
191 are considered
192 \image html geom_frameexp.jpg
193
194- 3 - bomb in radial spherical coordinate : TGeoManager::SetBombR()
195
196Volumes themselves support different visualization settings :
197 - TGeoVolume::SetVisibility() : set volume visibility.
198 - TGeoVolume::VisibleDaughters() : set daughters visibility.
199All these actions automatically updates the current view if any.
200
201### Checking the geometry
202
203 Several checking methods are accessible from the volume context menu. They
204generally apply only to the visible parts of the drawn geometry in order to
205ease geometry checking, and their implementation is in the TGeoChecker class
206from the painting package.
207
208#### Checking a given point.
209 Can be called from TGeoManager::CheckPoint(Double_t x, Double_t y, Double_t z).
210This method is drawing the daughters of the volume containing the point one
211level down, printing the path to the deepest physical node holding this point.
212It also computes the closest distance to any boundary. The point will be drawn
213in red, as well as a sphere having this closest distance as radius. In case a
214non-zero distance is given by the user as fifth argument of CheckPoint, this
215distance will be used as radius of the safety sphere.
216
217\image html geom_checkpoint.jpg
218
219#### Shooting random points.
220 Can be called from TGeoVolume::RandomPoints() (context menu function) and
221it will draw this volume with current visualization settings. Random points
222are generated in the bounding box of the top drawn volume. The points are
223classified and drawn with the color of their deepest container. Only points
224in visible nodes will be drawn.
225
226\image html geom_random1.jpg
227
228
229#### Raytracing.
230 Can be called from TGeoVolume::RandomRays() (context menu of volumes) and
231will shoot rays from a given point in the local reference frame with random
232directions. The intersections with displayed nodes will appear as segments
233having the color of the touched node. Drawn geometry will be then made invisible
234in order to enhance rays.
235
236\image html geom_random2.jpg
237*/
238
239#include <cstdlib>
240#include <iostream>
241#include <fstream>
242
243#include "TROOT.h"
244#include "TGeoManager.h"
245#include "TStyle.h"
246#include "TVirtualPad.h"
247#include "TBrowser.h"
248#include "TFile.h"
249#include "TKey.h"
250#include "THashList.h"
251#include "TClass.h"
252#include "ThreadLocalStorage.h"
253#include "TBufferText.h"
254
255#include "TGeoVoxelFinder.h"
256#include "TGeoElement.h"
257#include "TGeoMaterial.h"
258#include "TGeoMedium.h"
259#include "TGeoMatrix.h"
260#include "TGeoNode.h"
261#include "TGeoPhysicalNode.h"
262#include "TGeoPara.h"
263#include "TGeoParaboloid.h"
264#include "TGeoTube.h"
265#include "TGeoEltu.h"
266#include "TGeoHype.h"
267#include "TGeoCone.h"
268#include "TGeoSphere.h"
269#include "TGeoArb8.h"
270#include "TGeoPgon.h"
271#include "TGeoTrd1.h"
272#include "TGeoTrd2.h"
273#include "TGeoTorus.h"
274#include "TGeoXtru.h"
275#include "TGeoCompositeShape.h"
276#include "TGeoBoolNode.h"
277#include "TGeoBuilder.h"
278#include "TVirtualGeoPainter.h"
279#include "TVirtualGeoChecker.h"
280#include "TPluginManager.h"
281#include "TVirtualGeoTrack.h"
282#include "TQObject.h"
283#include "TMath.h"
284#include "TEnv.h"
285#include "TGeoParallelWorld.h"
286#include "TGeoRegion.h"
287#include "TGDMLMatrix.h"
288#include "TGeoOpticalSurface.h"
289
290// statics and globals
291
293
295
296std::mutex TGeoManager::fgMutex;
308
309////////////////////////////////////////////////////////////////////////////////
310/// Default constructor.
311
313{
314 if (!fgThreadId)
318 fTmin = 0.;
319 fTmax = 999.;
320 fPhiCut = kFALSE;
321 fPhimin = 0;
322 fPhimax = 360;
327 fClosed = kFALSE;
329 fBits = nullptr;
330 fCurrentNavigator = nullptr;
331 fMaterials = nullptr;
332 fHashPNE = nullptr;
333 fArrayPNE = nullptr;
334 fMatrices = nullptr;
335 fNodes = nullptr;
336 fOverlaps = nullptr;
337 fRegions = nullptr;
338 fNNodes = 0;
339 fMaxVisNodes = 10000;
340 fVolumes = nullptr;
341 fPhysicalNodes = nullptr;
342 fShapes = nullptr;
343 fGVolumes = nullptr;
344 fGShapes = nullptr;
345 fTracks = nullptr;
346 fMedia = nullptr;
347 fNtracks = 0;
348 fNpdg = 0;
349 fPdgNames = nullptr;
350 fGDMLMatrices = nullptr;
351 fOpticalSurfaces = nullptr;
352 fSkinSurfaces = nullptr;
353 fBorderSurfaces = nullptr;
354 memset(fPdgId, 0, 1024 * sizeof(Int_t));
355 // TObjArray *fNavigators; //! list of navigators
356 fCurrentTrack = nullptr;
357 fCurrentVolume = nullptr;
358 fTopVolume = nullptr;
359 fTopNode = nullptr;
360 fMasterVolume = nullptr;
361 fPainter = nullptr;
362 fChecker = nullptr;
365 fVisDensity = 0.;
366 fVisLevel = 3;
367 fVisOption = 1;
368 fExplodedView = 0;
369 fNsegments = 20;
370 fNLevel = 0;
371 fUniqueVolumes = nullptr;
372 fClippingShape = nullptr;
375 fGLMatrix = nullptr;
376 fPaintVolume = nullptr;
377 fUserPaintVolume = nullptr;
378 fElementTable = nullptr;
379 fHashVolumes = nullptr;
380 fHashGVolumes = nullptr;
381 fSizePNEId = 0;
382 fNPNEId = 0;
383 fKeyPNEId = nullptr;
384 fValuePNEId = nullptr;
386 fRaytraceMode = 0;
387 fMaxThreads = 0;
389 fParallelWorld = nullptr;
391 } else {
392 Init();
394 gGeoIdentity = new TGeoIdentity("Identity");
396 }
397}
398
399////////////////////////////////////////////////////////////////////////////////
400/// Constructor.
401
402TGeoManager::TGeoManager(const char *name, const char *title) : TNamed(name, title)
403{
404 if (!gROOT->GetListOfGeometries()->FindObject(this))
405 gROOT->GetListOfGeometries()->Add(this);
406 if (!gROOT->GetListOfBrowsables()->FindObject(this))
407 gROOT->GetListOfBrowsables()->Add(this);
408 Init();
409 gGeoIdentity = new TGeoIdentity("Identity");
411 if (fgVerboseLevel > 0)
412 Info("TGeoManager", "Geometry %s, %s created", GetName(), GetTitle());
413}
414
415////////////////////////////////////////////////////////////////////////////////
416/// Initialize manager class.
417
419{
420 if (gGeoManager) {
421 Warning("Init", "Deleting previous geometry: %s/%s", gGeoManager->GetName(), gGeoManager->GetTitle());
422 delete gGeoManager;
423 if (fgLock)
424 Fatal("Init", "New geometry created while the old one locked !!!");
425 }
426
427 gGeoManager = this;
428 if (!fgThreadId)
431 fTmin = 0.;
432 fTmax = 999.;
433 fPhiCut = kFALSE;
434 fPhimin = 0;
435 fPhimax = 360;
440 fClosed = kFALSE;
442 fBits = new UChar_t[50000]; // max 25000 nodes per volume
443 fCurrentNavigator = nullptr;
444 fHashPNE = new THashList(256, 3);
445 fArrayPNE = nullptr;
446 fMaterials = new THashList(200, 3);
447 fMatrices = new TObjArray(256);
448 fNodes = new TObjArray(30);
449 fOverlaps = new TObjArray(256);
450 fRegions = new TObjArray(256);
451 fNNodes = 0;
452 fMaxVisNodes = 10000;
453 fVolumes = new TObjArray(256);
454 fPhysicalNodes = new TObjArray(256);
455 fShapes = new TObjArray(256);
456 fGVolumes = new TObjArray(256);
457 fGShapes = new TObjArray(256);
458 fTracks = new TObjArray(256);
459 fMedia = new THashList(200, 3);
460 fNtracks = 0;
461 fNpdg = 0;
462 fPdgNames = nullptr;
463 fGDMLMatrices = new TObjArray();
465 fSkinSurfaces = new TObjArray();
467 memset(fPdgId, 0, 1024 * sizeof(Int_t));
468 fCurrentTrack = nullptr;
469 fCurrentVolume = nullptr;
470 fTopVolume = nullptr;
471 fTopNode = nullptr;
472 fMasterVolume = nullptr;
473 fPainter = nullptr;
474 fChecker = nullptr;
477 fVisDensity = 0.;
478 fVisLevel = 3;
479 fVisOption = 1;
480 fExplodedView = 0;
481 fNsegments = 20;
482 fNLevel = 0;
483 fUniqueVolumes = new TObjArray(256);
484 fClippingShape = nullptr;
487 fGLMatrix = new TGeoHMatrix();
488 fPaintVolume = nullptr;
489 fUserPaintVolume = nullptr;
490 fElementTable = nullptr;
491 fHashVolumes = nullptr;
492 fHashGVolumes = nullptr;
493 fSizePNEId = 0;
494 fNPNEId = 0;
495 fKeyPNEId = nullptr;
496 fValuePNEId = nullptr;
498 fRaytraceMode = 0;
499 fMaxThreads = 0;
501 fParallelWorld = nullptr;
503}
504
505////////////////////////////////////////////////////////////////////////////////
506/// Destructor
507
509{
510 if (gGeoManager != this)
511 gGeoManager = this;
513
514 if (gROOT->GetListOfFiles()) { // in case this function is called from TROOT destructor
515 gROOT->GetListOfGeometries()->Remove(this);
516 gROOT->GetListOfBrowsables()->Remove(this);
517 }
518 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
519 // TIter next(brlist);
520 // TBrowser *browser = 0;
521 // while ((browser=(TBrowser*)next())) browser->RecursiveRemove(this);
524 delete TGeoBuilder::Instance(this);
525 if (fBits)
526 delete[] fBits;
529 if (fOverlaps) {
530 fOverlaps->Delete();
532 }
533 if (fRegions) {
534 fRegions->Delete();
536 }
537 if (fMaterials) {
540 }
542 if (fMedia) {
543 fMedia->Delete();
545 }
546 if (fHashVolumes) {
547 fHashVolumes->Clear("nodelete");
549 }
550 if (fHashGVolumes) {
551 fHashGVolumes->Clear("nodelete");
553 }
554 if (fHashPNE) {
555 fHashPNE->Delete();
557 }
558 if (fArrayPNE) {
559 delete fArrayPNE;
560 }
561 if (fVolumes) {
562 fVolumes->Delete();
564 }
565 if (fShapes) {
566 fShapes->Delete();
568 }
569 if (fPhysicalNodes) {
572 }
573 if (fMatrices) {
574 fMatrices->Delete();
576 }
577 if (fTracks) {
578 fTracks->Delete();
580 }
582 if (fPdgNames) {
583 fPdgNames->Delete();
585 }
586 if (fGDMLMatrices) {
589 }
590 if (fOpticalSurfaces) {
593 }
594 if (fSkinSurfaces) {
597 }
598 if (fBorderSurfaces) {
601 }
603 CleanGarbage();
607 if (fSizePNEId) {
608 delete[] fKeyPNEId;
609 delete[] fValuePNEId;
610 }
611 delete fParallelWorld;
613 gGeoIdentity = nullptr;
614 gGeoManager = nullptr;
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Add a material to the list. Returns index of the material in list.
619
621{
622 return TGeoBuilder::Instance(this)->AddMaterial((TGeoMaterial *)material);
623}
624
625////////////////////////////////////////////////////////////////////////////////
626/// Add an illegal overlap/extrusion to the list.
627
634
635////////////////////////////////////////////////////////////////////////////////
636/// Add a new region of volumes.
643
644////////////////////////////////////////////////////////////////////////////////
645/// Add a user-defined property. Returns true if added, false if existing.
646
648{
649 auto pos = fProperties.insert(ConstPropMap_t::value_type(property, value));
650 if (!pos.second) {
651 Warning("AddProperty", "Property \"%s\" already exists with value %g", property, (pos.first)->second);
652 return false;
653 }
654 return true;
655}
656
657////////////////////////////////////////////////////////////////////////////////
658/// Get a user-defined property
659
661{
662 auto pos = fProperties.find(property);
663 if (pos == fProperties.end()) {
664 if (error)
665 *error = kTRUE;
666 return 0.;
667 }
668 if (error)
669 *error = kFALSE;
670 return pos->second;
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// Get a user-defined property from a given index
675
677{
678 // This is a quite inefficient way to access map elements, but needed for the GDML writer to
679 if (i >= fProperties.size()) {
680 if (error)
681 *error = kTRUE;
682 return 0.;
683 }
684 size_t pos = 0;
685 auto it = fProperties.begin();
686 while (pos < i) {
687 ++it;
688 ++pos;
689 }
690 if (error)
691 *error = kFALSE;
692 name = (*it).first;
693 return (*it).second;
694}
695
696////////////////////////////////////////////////////////////////////////////////
697/// Add a matrix to the list. Returns index of the matrix in list.
698
700{
701 return TGeoBuilder::Instance(this)->AddTransformation((TGeoMatrix *)matrix);
702}
703
704////////////////////////////////////////////////////////////////////////////////
705/// Add a shape to the list. Returns index of the shape in list.
706
708{
709 return TGeoBuilder::Instance(this)->AddShape((TGeoShape *)shape);
710}
711
712////////////////////////////////////////////////////////////////////////////////
713/// Add a track to the list of tracks. Use this for primaries only. For secondaries,
714/// add them to the parent track. The method create objects that are registered
715/// to the analysis manager but have to be cleaned-up by the user via ClearTracks().
716
723
724////////////////////////////////////////////////////////////////////////////////
725/// Add a track to the list of tracks
726
733
734////////////////////////////////////////////////////////////////////////////////
735/// Makes a primary track but do not attach it to the list of tracks. The track
736/// can be attached as daughter to another one with TVirtualGeoTrack::AddTrack
737
743
744////////////////////////////////////////////////////////////////////////////////
745/// Add a volume to the list. Returns index of the volume in list.
746
748{
749 if (!volume) {
750 Error("AddVolume", "invalid volume");
751 return -1;
752 }
754 if (!uid)
755 uid++;
756 if (!fCurrentVolume) {
757 fCurrentVolume = volume;
758 fUniqueVolumes->AddAtAndExpand(volume, uid);
759 } else {
760 if (!strcmp(volume->GetName(), fCurrentVolume->GetName())) {
761 uid = fCurrentVolume->GetNumber();
762 } else {
763 fCurrentVolume = volume;
764 Int_t olduid = GetUID(volume->GetName());
765 if (olduid < 0) {
766 fUniqueVolumes->AddAtAndExpand(volume, uid);
767 } else {
768 uid = olduid;
769 }
770 }
771 }
772 volume->SetNumber(uid);
773 if (!fHashVolumes) {
774 fHashVolumes = new THashList(256);
775 fHashGVolumes = new THashList(256);
776 }
777 TObjArray *list = fVolumes;
778 if (!volume->GetShape() || volume->IsRunTime() || volume->IsVolumeMulti()) {
779 list = fGVolumes;
780 fHashGVolumes->Add(volume);
781 } else {
782 fHashVolumes->Add(volume);
783 }
784 Int_t index = list->GetEntriesFast();
785 list->AddAtAndExpand(volume, index);
786 return uid;
787}
788
789////////////////////////////////////////////////////////////////////////////////
790/// Add a navigator in the list of navigators. If it is the first one make it
791/// current navigator.
792
794{
795 if (fMultiThread) {
797 fgMutex.lock();
798 }
799 std::thread::id threadId = std::this_thread::get_id();
800 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
801 TGeoNavigatorArray *array = nullptr;
802 if (it != fNavigators.end())
803 array = it->second;
804 else {
805 array = new TGeoNavigatorArray(this);
806 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
807 }
808 TGeoNavigator *nav = array->AddNavigator();
809 if (fClosed)
810 nav->GetCache()->BuildInfoBranch();
811 if (fMultiThread)
812 fgMutex.unlock();
813 return nav;
814}
815
816////////////////////////////////////////////////////////////////////////////////
817/// Returns current navigator for the calling thread.
818
820{
821 TTHREAD_TLS(TGeoNavigator *) tnav = nullptr;
822 if (!fMultiThread)
823 return fCurrentNavigator;
824 TGeoNavigator *nav = tnav; // TTHREAD_TLS_GET(TGeoNavigator*,tnav);
825 if (nav)
826 return nav;
827 std::thread::id threadId = std::this_thread::get_id();
828 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
829 if (it == fNavigators.end())
830 return nullptr;
831 TGeoNavigatorArray *array = it->second;
832 nav = array->GetCurrentNavigator();
833 tnav = nav; // TTHREAD_TLS_SET(TGeoNavigator*,tnav,nav);
834 return nav;
835}
836
837////////////////////////////////////////////////////////////////////////////////
838/// Get list of navigators for the calling thread.
839
841{
842 std::thread::id threadId = std::this_thread::get_id();
843 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
844 if (it == fNavigators.end())
845 return nullptr;
846 TGeoNavigatorArray *array = it->second;
847 return array;
848}
849
850////////////////////////////////////////////////////////////////////////////////
851/// Switch to another existing navigator for the calling thread.
852
854{
855 std::thread::id threadId = std::this_thread::get_id();
856 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
857 if (it == fNavigators.end()) {
858 Error("SetCurrentNavigator", "No navigator defined for this thread\n");
859 std::cout << " thread id: " << threadId << std::endl;
860 return kFALSE;
861 }
862 TGeoNavigatorArray *array = it->second;
864 if (!nav) {
865 Error("SetCurrentNavigator", "Navigator %d not existing for this thread\n", index);
866 std::cout << " thread id: " << threadId << std::endl;
867 return kFALSE;
868 }
869 if (!fMultiThread)
871 return kTRUE;
872}
873
874////////////////////////////////////////////////////////////////////////////////
875/// Set the lock for navigators.
876
881
882////////////////////////////////////////////////////////////////////////////////
883/// Clear all navigators.
884
886{
887 if (fMultiThread)
888 fgMutex.lock();
889 TGeoNavigatorArray *arr = nullptr;
890 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
891 arr = (*it).second;
892 if (arr)
893 delete arr;
894 }
895 fNavigators.clear();
896 if (fMultiThread)
897 fgMutex.unlock();
898}
899
900////////////////////////////////////////////////////////////////////////////////
901/// Clear a single navigator.
902
904{
905 if (fMultiThread)
906 fgMutex.lock();
907 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
908 TGeoNavigatorArray *arr = (*it).second;
909 if (arr) {
910 if ((TGeoNavigator *)arr->Remove((TObject *)nav)) {
911 delete nav;
912 if (!arr->GetEntries())
913 fNavigators.erase(it);
914 if (fMultiThread)
915 fgMutex.unlock();
916 return;
917 }
918 }
919 }
920 Error("Remove navigator", "Navigator %p not found", nav);
921 if (fMultiThread)
922 fgMutex.unlock();
923}
924
925////////////////////////////////////////////////////////////////////////////////
926/// Set maximum number of threads for navigation.
927
929{
930 if (!fClosed) {
931 Error("SetMaxThreads", "Cannot set maximum number of threads before closing the geometry");
932 return;
933 }
934 if (!fMultiThread) {
936 std::thread::id threadId = std::this_thread::get_id();
937 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
938 if (it != fNavigators.end()) {
939 TGeoNavigatorArray *array = it->second;
940 fNavigators.erase(it);
941 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
942 }
943 }
944 if (fMaxThreads) {
947 }
948 fMaxThreads = nthreads + 1;
949 if (fMaxThreads > 0) {
952 }
953}
954
955////////////////////////////////////////////////////////////////////////////////
956
958{
959 if (!fMaxThreads)
960 return;
961 fgMutex.lock();
962 TIter next(fVolumes);
963 TGeoVolume *vol;
964 while ((vol = (TGeoVolume *)next()))
965 vol->ClearThreadData();
966 fgMutex.unlock();
967}
968
969////////////////////////////////////////////////////////////////////////////////
970/// Create thread private data for all geometry objects.
971
973{
974 if (!fMaxThreads)
975 return;
976 fgMutex.lock();
977 TIter next(fVolumes);
978 TGeoVolume *vol;
979 while ((vol = (TGeoVolume *)next()))
981 fgMutex.unlock();
982}
983
984////////////////////////////////////////////////////////////////////////////////
985/// Clear the current map of threads. This will be filled again by the calling
986/// threads via ThreadId calls.
987
989{
991 return;
992 fgMutex.lock();
993 if (!fgThreadId->empty())
994 fgThreadId->clear();
995 fgNumThreads = 0;
996 fgMutex.unlock();
997}
998
999////////////////////////////////////////////////////////////////////////////////
1000/// Translates the current thread id to an ordinal number. This can be used to
1001/// manage data which is specific for a given thread.
1002
1004{
1005 TTHREAD_TLS(Int_t) tid = -1;
1006 Int_t ttid = tid; // TTHREAD_TLS_GET(Int_t,tid);
1007 if (ttid > -1)
1008 return ttid;
1010 return 0;
1011 std::thread::id threadId = std::this_thread::get_id();
1013 if (it != fgThreadId->end())
1014 return it->second;
1015 // Map needs to be updated.
1016 fgMutex.lock();
1017 (*fgThreadId)[threadId] = fgNumThreads;
1018 tid = fgNumThreads; // TTHREAD_TLS_SET(Int_t,tid,fgNumThreads);
1019 ttid = fgNumThreads++;
1020 fgMutex.unlock();
1021 return ttid;
1022}
1023
1024////////////////////////////////////////////////////////////////////////////////
1025/// Describe how to browse this object.
1026
1028{
1029 if (!b)
1030 return;
1031 if (fMaterials)
1032 b->Add(fMaterials, "Materials");
1033 if (fMedia)
1034 b->Add(fMedia, "Media");
1035 if (fMatrices)
1036 b->Add(fMatrices, "Local transformations");
1037 if (fOverlaps)
1038 b->Add(fOverlaps, "Illegal overlaps");
1039 if (fTracks)
1040 b->Add(fTracks, "Tracks");
1041 if (fMasterVolume)
1042 b->Add(fMasterVolume, "Master Volume", fMasterVolume->IsVisible());
1043 if (fTopVolume)
1044 b->Add(fTopVolume, "Top Volume", fTopVolume->IsVisible());
1045 if (fTopNode)
1046 b->Add(fTopNode);
1047 TString browserImp(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
1048 TQObject::Connect(browserImp.Data(), "Checked(TObject*,Bool_t)", "TGeoManager", this,
1049 "SetVisibility(TObject*,Bool_t)");
1050}
1051
1052////////////////////////////////////////////////////////////////////////////////
1053/// Append a pad for this geometry.
1054
1060
1061////////////////////////////////////////////////////////////////////////////////
1062/// Set visibility for a volume.
1063
1065{
1066 if (obj->IsA() == TGeoVolume::Class()) {
1067 TGeoVolume *vol = (TGeoVolume *)obj;
1068 vol->SetVisibility(vis);
1069 } else {
1070 if (obj->InheritsFrom(TGeoNode::Class())) {
1071 TGeoNode *node = (TGeoNode *)obj;
1072 node->SetVisibility(vis);
1073 } else
1074 return;
1075 }
1077}
1078
1079////////////////////////////////////////////////////////////////////////////////
1080/// Get the new 'bombed' translation vector according current exploded view mode.
1081
1083{
1084 if (fPainter)
1086 return;
1087}
1088
1089////////////////////////////////////////////////////////////////////////////////
1090/// Get the new 'unbombed' translation vector according current exploded view mode.
1091
1093{
1094 if (fPainter)
1096 return;
1097}
1098
1099////////////////////////////////////////////////////////////////////////////////
1100/// Backup the current state without affecting the cache stack.
1101
1106
1107////////////////////////////////////////////////////////////////////////////////
1108/// Restore a backed-up state without affecting the cache stack.
1109
1114
1115////////////////////////////////////////////////////////////////////////////////
1116/// Register a matrix to the list of matrices. It will be cleaned-up at the
1117/// destruction TGeoManager.
1118
1120{
1121 return TGeoBuilder::Instance(this)->RegisterMatrix((TGeoMatrix *)matrix);
1122}
1123
1124////////////////////////////////////////////////////////////////////////////////
1125/// Replaces all occurrences of VORIG with VNEW in the geometry tree. The volume VORIG
1126/// is not replaced from the list of volumes, but all node referencing it will reference
1127/// VNEW instead. Returns number of occurrences changed.
1128
1130{
1131 Int_t nref = 0;
1132 if (!vorig || !vnew)
1133 return nref;
1134 TGeoMedium *morig = vorig->GetMedium();
1136 if (morig)
1137 checkmed = kTRUE;
1138 TGeoMedium *mnew = vnew->GetMedium();
1139 // Try to limit the damage produced by incorrect usage.
1140 if (!mnew && !vnew->IsAssembly()) {
1141 Error("ReplaceVolume", "Replacement volume %s has no medium and it is not an assembly", vnew->GetName());
1142 return nref;
1143 }
1144 if (mnew && checkmed) {
1145 if (mnew->GetId() != morig->GetId())
1146 Warning("ReplaceVolume", "Replacement volume %s has different medium than original volume %s", vnew->GetName(),
1147 vorig->GetName());
1148 checkmed = kFALSE;
1149 }
1150
1151 // Medium checking now performed only if replacement is an assembly and old volume a real one.
1152 // Check result is dependent on positioning.
1154 Int_t i, j, nd;
1155 Int_t ierr = 0;
1156 TGeoVolume *vol;
1157 TGeoNode *node;
1159 for (i = 0; i < nvol; i++) {
1160 vol = (TGeoVolume *)fVolumes->At(i);
1161 if (!vol)
1162 continue;
1163 if (vol == vorig || vol == vnew)
1164 continue;
1165 nd = vol->GetNdaughters();
1166 for (j = 0; j < nd; j++) {
1167 node = vol->GetNode(j);
1168 if (node->GetVolume() == vorig) {
1169 if (checkmed) {
1170 mnew = node->GetMotherVolume()->GetMedium();
1171 if (mnew && mnew->GetId() != morig->GetId())
1172 ierr++;
1173 }
1174 nref++;
1175 if (node->IsOverlapping()) {
1176 node->SetOverlapping(kFALSE);
1177 Info("ReplaceVolume", "%s replaced with assembly and declared NON-OVERLAPPING!", node->GetName());
1178 }
1179 node->SetVolume(vnew);
1180 voxels = node->GetMotherVolume()->GetVoxels();
1181 if (voxels)
1182 voxels->SetNeedRebuild();
1183 } else {
1184 if (node->GetMotherVolume() == vorig) {
1185 nref++;
1186 node->SetMotherVolume(vnew);
1187 if (node->IsOverlapping()) {
1188 node->SetOverlapping(kFALSE);
1189 Info("ReplaceVolume", "%s inside substitute assembly %s declared NON-OVERLAPPING!", node->GetName(),
1190 vnew->GetName());
1191 }
1192 }
1193 }
1194 }
1195 }
1196 if (ierr)
1197 Warning("ReplaceVolume",
1198 "Volumes should not be replaced with assemblies if they are positioned in containers having a different "
1199 "medium ID.\n %i occurrences for assembly replacing volume %s",
1200 ierr, vorig->GetName());
1201 return nref;
1202}
1203
1204////////////////////////////////////////////////////////////////////////////////
1205/// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1206
1208{
1210 if (!toTransform) {
1211 Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1212 return 0;
1213 }
1215 Int_t count = 0;
1217 Bool_t replace = kTRUE;
1219 while (index < indmax) {
1220 if (replace) {
1221 replace = kFALSE;
1223 if (transformed) {
1225 count++;
1226 } else {
1227 if (toTransform->IsAssembly())
1228 Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1229 if (!toTransform->GetNdaughters())
1230 Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform",
1231 toTransform->GetName());
1232 if (toTransform->IsVolumeMulti())
1233 Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1234 }
1235 }
1236 index++;
1237 if (index >= indmax)
1238 return count;
1240 if (!strcmp(toTransform->GetName(), vname))
1241 replace = kTRUE;
1242 }
1243 return count;
1244}
1245
1246////////////////////////////////////////////////////////////////////////////////
1247/// Create a new volume by dividing an existing one (GEANT3 like)
1248///
1249/// Divides MOTHER into NDIV divisions called NAME
1250/// along axis IAXIS starting at coordinate value START
1251/// and having size STEP. The created volumes will have tracking
1252/// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1253/// The behavior of the division operation can be triggered using OPTION :
1254///
1255/// OPTION (case insensitive) :
1256/// - N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1257/// - NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1258/// - S - divide all range with given STEP. NDIV is computed and divisions will be centered
1259/// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1260/// - SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1261
1262TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start,
1264{
1265 return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1266}
1267
1268////////////////////////////////////////////////////////////////////////////////
1269/// Create rotation matrix named 'mat<index>'.
1270///
1271/// - index rotation matrix number
1272/// - theta1 polar angle for axis X
1273/// - phi1 azimuthal angle for axis X
1274/// - theta2 polar angle for axis Y
1275/// - phi2 azimuthal angle for axis Y
1276/// - theta3 polar angle for axis Z
1277/// - phi3 azimuthal angle for axis Z
1278///
1279
1285
1286////////////////////////////////////////////////////////////////////////////////
1287/// Create material with given A, Z and density, having an unique id.
1288
1291{
1292 return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1293}
1294
1295////////////////////////////////////////////////////////////////////////////////
1296/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1297/// materials defined by arrays A,Z and WMAT, having an unique id.
1298
1301{
1302 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1303}
1304
1305////////////////////////////////////////////////////////////////////////////////
1306/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1307/// materials defined by arrays A,Z and WMAT, having an unique id.
1308
1311{
1312 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1313}
1314
1315////////////////////////////////////////////////////////////////////////////////
1316/// Create tracking medium
1317///
1318/// - numed tracking medium number assigned
1319/// - name tracking medium name
1320/// - nmat material number
1321/// - isvol sensitive volume flag
1322/// - ifield magnetic field
1323/// - fieldm max. field value (kilogauss)
1324/// - tmaxfd max. angle due to field (deg/step)
1325/// - stemax max. step allowed
1326/// - deemax max. fraction of energy lost in a step
1327/// - epsil tracking precision (cm)
1328/// - stmin min. step due to continuous processes (cm)
1329///
1330/// - ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1331/// - ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1332/// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1333///
1334
1341
1342////////////////////////////////////////////////////////////////////////////////
1343/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1344/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1345/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1346/// In case npar>0, create the volume to be positioned in mother, according
1347/// its actual parameters (gsposp).
1348/// - NAME Volume name
1349/// - NUMBER Copy number of the volume
1350/// - MOTHER Mother volume name
1351/// - X X coord. of the volume in mother ref. sys.
1352/// - Y Y coord. of the volume in mother ref. sys.
1353/// - Z Z coord. of the volume in mother ref. sys.
1354/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1355/// - ISONLY ONLY/MANY flag
1356
1359{
1360 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1361}
1362
1363////////////////////////////////////////////////////////////////////////////////
1364/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1365/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1366/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1367/// In case npar>0, create the volume to be positioned in mother, according
1368/// its actual parameters (gsposp).
1369/// - NAME Volume name
1370/// - NUMBER Copy number of the volume
1371/// - MOTHER Mother volume name
1372/// - X X coord. of the volume in mother ref. sys.
1373/// - Y Y coord. of the volume in mother ref. sys.
1374/// - Z Z coord. of the volume in mother ref. sys.
1375/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1376/// - ISONLY ONLY/MANY flag
1377
1380{
1381 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1382}
1383
1384////////////////////////////////////////////////////////////////////////////////
1385/// Create a volume in GEANT3 style.
1386/// - NAME Volume name
1387/// - SHAPE Volume type
1388/// - NMED Tracking medium number
1389/// - NPAR Number of shape parameters
1390/// - UPAR Vector containing shape parameters
1391
1392TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar)
1393{
1394 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1395}
1396
1397////////////////////////////////////////////////////////////////////////////////
1398/// Create a volume in GEANT3 style.
1399/// - NAME Volume name
1400/// - SHAPE Volume type
1401/// - NMED Tracking medium number
1402/// - NPAR Number of shape parameters
1403/// - UPAR Vector containing shape parameters
1404
1406{
1407 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1408}
1409
1410////////////////////////////////////////////////////////////////////////////////
1411/// Assigns uid's for all materials,media and matrices.
1412
1414{
1415 Int_t index = 1;
1416 TIter next(fMaterials);
1418 while ((mater = (TGeoMaterial *)next())) {
1419 mater->SetUniqueID(index++);
1421 }
1422 index = 1;
1424 TGeoMedium *med;
1425 while ((med = (TGeoMedium *)next1())) {
1426 med->SetUniqueID(index++);
1428 }
1429 index = 1;
1431 TGeoShape *shape;
1432 while ((shape = (TGeoShape *)next2())) {
1433 shape->SetUniqueID(index++);
1434 if (shape->IsComposite())
1435 ((TGeoCompositeShape *)shape)->GetBoolNode()->RegisterMatrices();
1436 }
1437
1440 while ((matrix = (TGeoMatrix *)next3())) {
1441 matrix->RegisterYourself();
1442 }
1444 index = 1;
1445 while ((matrix = (TGeoMatrix *)next4())) {
1446 matrix->SetUniqueID(index++);
1448 }
1450 TGeoVolume *vol;
1451 while ((vol = (TGeoVolume *)next5()))
1452 vol->UnmarkSaved();
1453}
1454
1455////////////////////////////////////////////////////////////////////////////////
1456/// Reset all attributes to default ones. Default attributes for visualization
1457/// are those defined before closing the geometry.
1458
1460{
1461 if (gPad)
1462 delete gPad;
1463 gPad = nullptr;
1464 SetVisOption(0);
1465 SetVisLevel(3);
1466 SetExplodedView(0);
1468 if (!gStyle)
1469 return;
1470 TIter next(fVolumes);
1471 TGeoVolume *vol = nullptr;
1472 while ((vol = (TGeoVolume *)next())) {
1473 if (!vol->IsVisTouched())
1474 continue;
1475 vol->SetVisTouched(kFALSE);
1476 }
1477}
1478////////////////////////////////////////////////////////////////////////////////
1479/// Closing geometry implies checking the geometry validity, fixing shapes
1480/// with negative parameters (run-time shapes)building the cache manager,
1481/// voxelizing all volumes, counting the total number of physical nodes and
1482/// registering the manager class to the browser.
1483
1485{
1486 if (fClosed) {
1487 Warning("CloseGeometry", "geometry already closed");
1488 return;
1489 }
1490 if (!fMasterVolume) {
1491 Error("CloseGeometry", "you MUST call SetTopVolume() first !");
1492 return;
1493 }
1494 if (!gROOT->GetListOfGeometries()->FindObject(this))
1495 gROOT->GetListOfGeometries()->Add(this);
1496 if (!gROOT->GetListOfBrowsables()->FindObject(this))
1497 gROOT->GetListOfBrowsables()->Add(this);
1498 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1499 // TIter next(brlist);
1500 // TBrowser *browser = 0;
1501 // while ((browser=(TBrowser*)next())) browser->Refresh();
1502 TString opt(option);
1503 opt.ToLower();
1504 // Bool_t dummy = opt.Contains("d");
1505 Bool_t nodeid = opt.Contains("i");
1506 // Create a geometry navigator if not present
1507 TGeoNavigator *nav = nullptr;
1508 Int_t nnavigators = 0;
1509 // Check if the geometry is streamed from file
1510 if (fIsGeomReading) {
1511 if (fgVerboseLevel > 0)
1512 Info("CloseGeometry", "Geometry loaded from file...");
1514 if (!fElementTable)
1516 if (!fTopNode) {
1517 if (!fMasterVolume) {
1518 Error("CloseGeometry", "Master volume not streamed");
1519 return;
1520 }
1522 if (fStreamVoxels && fgVerboseLevel > 0)
1523 Info("CloseGeometry", "Voxelization retrieved from file");
1524 }
1525 // Create a geometry navigator if not present
1526 if (!GetCurrentNavigator())
1529 if (!opt.Contains("nv")) {
1530 Voxelize("ALL");
1531 }
1532 CountLevels();
1533 for (Int_t i = 0; i < nnavigators; i++) {
1535 nav->GetCache()->BuildInfoBranch();
1536 if (nodeid)
1537 nav->GetCache()->BuildIdArray();
1538 }
1539 if (!fHashVolumes) {
1542 fHashVolumes = new THashList(nvol + 1);
1543 fHashGVolumes = new THashList(ngvol + 1);
1544 Int_t i;
1545 for (i = 0; i < ngvol; i++)
1547 for (i = 0; i < nvol; i++)
1549 }
1550 fClosed = kTRUE;
1551 if (fParallelWorld) {
1552 if (fgVerboseLevel > 0)
1553 Info("CloseGeometry", "Recreating parallel world %s ...", fParallelWorld->GetName());
1555 }
1556
1557 if (fgVerboseLevel > 0)
1558 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1559 GetTitle());
1560 if (fgVerboseLevel > 0)
1561 Info("CloseGeometry", "----------------modeler ready----------------");
1562 return;
1563 }
1564
1565 // Create a geometry navigator if not present
1566 if (!GetCurrentNavigator())
1570 CheckGeometry();
1571 if (fgVerboseLevel > 0)
1572 Info("CloseGeometry", "Counting nodes...");
1573 fNNodes = CountNodes();
1574 fNLevel = fMasterVolume->CountNodes(1, 3) + 1;
1575 if (fNLevel < 30)
1576 fNLevel = 100;
1577
1578 // BuildIdArray();
1579 // avoid voxelization if requested to speed up geometry startup
1580 if (!opt.Contains("nv")) {
1581 Voxelize("ALL");
1582 } else {
1583 TGeoVolume *vol;
1584 TIter next(fVolumes);
1585 while ((vol = (TGeoVolume *)next())) {
1586 vol->SortNodes();
1587 }
1588 }
1589 if (fgVerboseLevel > 0)
1590 Info("CloseGeometry", "Building cache...");
1591 CountLevels();
1592 for (Int_t i = 0; i < nnavigators; i++) {
1594 nav->GetCache()->BuildInfoBranch();
1595 if (nodeid)
1596 nav->GetCache()->BuildIdArray();
1597 }
1598 fClosed = kTRUE;
1599 if (fgVerboseLevel > 0) {
1600 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1601 GetTitle());
1602 Info("CloseGeometry", "----------------modeler ready----------------");
1603 }
1604}
1605
1606////////////////////////////////////////////////////////////////////////////////
1607/// Clear the list of overlaps.
1608
1610{
1611 if (fOverlaps) {
1612 fOverlaps->Delete();
1613 delete fOverlaps;
1614 }
1615 fOverlaps = new TObjArray();
1616}
1617
1618////////////////////////////////////////////////////////////////////////////////
1619/// Remove a shape from the list of shapes.
1620
1622{
1623 if (fShapes->FindObject(shape))
1624 fShapes->Remove((TGeoShape *)shape);
1625 delete shape;
1626}
1627
1628////////////////////////////////////////////////////////////////////////////////
1629/// Clean temporary volumes and shapes from garbage collection.
1630
1632{
1633 if (!fGVolumes && !fGShapes)
1634 return;
1635 Int_t i, nentries;
1636 if (fGVolumes) {
1638 TGeoVolume *vol = nullptr;
1639 for (i = 0; i < nentries; i++) {
1640 vol = (TGeoVolume *)fGVolumes->At(i);
1641 if (vol)
1642 vol->SetFinder(nullptr);
1643 }
1644 fGVolumes->Delete();
1645 delete fGVolumes;
1646 fGVolumes = nullptr;
1647 }
1648 if (fGShapes) {
1649 fGShapes->Delete();
1650 delete fGShapes;
1651 fGShapes = nullptr;
1652 }
1653}
1654
1655////////////////////////////////////////////////////////////////////////////////
1656/// Change current path to point to the node having this id.
1657/// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1658
1660{
1661 GetCurrentNavigator()->CdNode(nodeid);
1662}
1663
1664////////////////////////////////////////////////////////////////////////////////
1665/// Get the unique ID of the current node.
1666
1671
1672////////////////////////////////////////////////////////////////////////////////
1673/// Make top level node the current node. Updates the cache accordingly.
1674/// Determine the overlapping state of current node.
1675
1677{
1679}
1680
1681////////////////////////////////////////////////////////////////////////////////
1682/// Go one level up in geometry. Updates cache accordingly.
1683/// Determine the overlapping state of current node.
1684
1686{
1688}
1689
1690////////////////////////////////////////////////////////////////////////////////
1691/// Make a daughter of current node current. Can be called only with a valid
1692/// daughter index (no check). Updates cache accordingly.
1693
1698
1699////////////////////////////////////////////////////////////////////////////////
1700/// Do a cd to the node found next by FindNextBoundary
1701
1703{
1705}
1706
1707////////////////////////////////////////////////////////////////////////////////
1708/// Browse the tree of nodes starting from fTopNode according to pathname.
1709/// Changes the path accordingly.
1710
1711Bool_t TGeoManager::cd(const char *path)
1712{
1713 return GetCurrentNavigator()->cd(path);
1714}
1715
1716////////////////////////////////////////////////////////////////////////////////
1717/// Check if a geometry path is valid without changing the state of the current navigator.
1718
1719Bool_t TGeoManager::CheckPath(const char *path) const
1720{
1721 return GetCurrentNavigator()->CheckPath(path);
1722}
1723
1724////////////////////////////////////////////////////////////////////////////////
1725/// Convert all reflections in geometry to normal rotations + reflected shapes.
1726
1728{
1729 if (!fTopNode)
1730 return;
1731 if (fgVerboseLevel > 0)
1732 Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1734 TGeoNode *node;
1738 while ((node = next())) {
1739 matrix = node->GetMatrix();
1740 if (matrix->IsReflection()) {
1741 // printf("%s before\n", node->GetName());
1742 // matrix->Print();
1744 mclone->RegisterYourself();
1745 // Reflect just the rotation component
1746 mclone->ReflectZ(kFALSE, kTRUE);
1747 nodematrix = (TGeoNodeMatrix *)node;
1748 nodematrix->SetMatrix(mclone);
1749 // printf("%s after\n", node->GetName());
1750 // node->GetMatrix()->Print();
1752 node->SetVolume(reflected);
1753 }
1754 }
1755 if (fgVerboseLevel > 0)
1756 Info("ConvertReflections", "Done");
1757}
1758
1759////////////////////////////////////////////////////////////////////////////////
1760/// Count maximum number of nodes per volume, maximum depth and maximum
1761/// number of xtru vertices.
1762
1764{
1765 if (!fTopNode) {
1766 Error("CountLevels", "Top node not defined.");
1767 return;
1768 }
1771 if (fMasterVolume->GetRefCount() > 1)
1773 if (fgVerboseLevel > 1 && fixrefs)
1774 Info("CountLevels", "Fixing volume reference counts");
1775 TGeoNode *node;
1776 Int_t maxlevel = 1;
1778 Int_t maxvertices = 1;
1779 while ((node = next())) {
1780 if (fixrefs) {
1781 node->GetVolume()->Grab();
1782 for (Int_t ibit = 10; ibit < 14; ibit++) {
1783 node->SetBit(BIT(ibit + 4), node->TestBit(BIT(ibit)));
1784 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1785 }
1786 }
1787 if (node->GetNdaughters() > maxnodes)
1788 maxnodes = node->GetNdaughters();
1789 if (next.GetLevel() > maxlevel)
1790 maxlevel = next.GetLevel();
1791 if (node->GetVolume()->GetShape()->IsA() == TGeoXtru::Class()) {
1792 TGeoXtru *xtru = (TGeoXtru *)node->GetVolume()->GetShape();
1793 if (xtru->GetNvert() > maxvertices)
1794 maxvertices = xtru->GetNvert();
1795 }
1796 }
1800 if (fgVerboseLevel > 0)
1801 Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1802}
1803
1804////////////////////////////////////////////////////////////////////////////////
1805/// Count the total number of nodes starting from a volume, nlevels down.
1806
1808{
1809 TGeoVolume *top;
1810 if (!vol) {
1811 top = fTopVolume;
1812 } else {
1813 top = (TGeoVolume *)vol;
1814 }
1815 Int_t count = top->CountNodes(nlevels, option);
1816 return count;
1817}
1818
1819////////////////////////////////////////////////////////////////////////////////
1820/// Set default angles for a given view.
1821
1823{
1824 if (fPainter)
1826}
1827
1828////////////////////////////////////////////////////////////////////////////////
1829/// Draw current point in the same view.
1830
1832{
1833 if (fPainter)
1834 fPainter->DrawCurrentPoint(color);
1835}
1836
1837////////////////////////////////////////////////////////////////////////////////
1838/// Draw animation of tracks
1839
1841{
1844 if (tmin < 0 || tmin >= tmax || nframes < 1)
1845 return;
1847 box[0] = box[1] = box[2] = 0;
1848 box[3] = box[4] = box[5] = 100;
1849 Double_t dt = (tmax - tmin) / Double_t(nframes);
1850 Double_t delt = 2E-9;
1851 Double_t t = tmin;
1852 Int_t i, j;
1853 TString opt(option);
1854 Bool_t save = kFALSE, geomanim = kFALSE;
1855 TString fname;
1856 if (opt.Contains("/S"))
1857 save = kTRUE;
1858
1859 if (opt.Contains("/G"))
1860 geomanim = kTRUE;
1861 SetTminTmax(0, 0);
1862 DrawTracks(opt.Data());
1863 Double_t start[6] = {0, 0, 0, 0, 0, 0};
1864 Double_t end[6] = {0, 0, 0, 0, 0, 0};
1865 Double_t dd[6] = {0, 0, 0, 0, 0, 0};
1866 Double_t dlat = 0, dlong = 0, dpsi = 0;
1867 if (geomanim) {
1868 fPainter->EstimateCameraMove(tmin + 5 * dt, tmin + 15 * dt, start, end);
1869 for (i = 0; i < 3; i++) {
1870 start[i + 3] = 20 + 1.3 * start[i + 3];
1871 end[i + 3] = 20 + 0.9 * end[i + 3];
1872 }
1873 for (i = 0; i < 6; i++) {
1874 dd[i] = (end[i] - start[i]) / 10.;
1875 }
1876 memcpy(box, start, 6 * sizeof(Double_t));
1878 dlong = (-206 - dlong) / Double_t(nframes);
1879 dlat = (126 - dlat) / Double_t(nframes);
1880 dpsi = (75 - dpsi) / Double_t(nframes);
1882 }
1883
1884 for (i = 0; i < nframes; i++) {
1885 if (t - delt < 0)
1886 SetTminTmax(t - delt, t);
1887 else
1888 gGeoManager->SetTminTmax(t - delt, t);
1889 if (geomanim) {
1890 for (j = 0; j < 6; j++)
1891 box[j] += dd[j];
1893 } else {
1894 ModifiedPad();
1895 }
1896 if (save) {
1897 fname = TString::Format("anim%04d.gif", i);
1898 gPad->Print(fname);
1899 }
1900 t += dt;
1901 }
1903}
1904
1905////////////////////////////////////////////////////////////////////////////////
1906/// Draw tracks over the geometry, according to option. By default, only
1907/// primaries are drawn. See TGeoTrack::Draw() for additional options.
1908
1910{
1912 // SetVisLevel(1);
1913 // SetVisOption(1);
1915 for (Int_t i = 0; i < fNtracks; i++) {
1916 track = GetTrack(i);
1917 if (track)
1918 track->Draw(option);
1919 }
1921 ModifiedPad();
1922}
1923
1924////////////////////////////////////////////////////////////////////////////////
1925/// Draw current path
1926
1927void TGeoManager::DrawPath(const char *path, Option_t *option)
1928{
1929 if (!fTopVolume)
1930 return;
1932 GetGeomPainter()->DrawPath(path, option);
1933}
1934
1935////////////////////////////////////////////////////////////////////////////////
1936/// Draw random points in the bounding box of a volume.
1937
1942
1943////////////////////////////////////////////////////////////////////////////////
1944/// Check time of finding "Where am I" for n points.
1945
1950
1951////////////////////////////////////////////////////////////////////////////////
1952/// Geometry overlap checker based on sampling.
1953
1954void TGeoManager::TestOverlaps(const char *path)
1955{
1957}
1958
1959////////////////////////////////////////////////////////////////////////////////
1960/// Fill volume names of current branch into an array.
1961
1963{
1965}
1966
1967////////////////////////////////////////////////////////////////////////////////
1968/// Get name for given pdg code;
1969
1971{
1972 static char defaultname[5] = {"XXX"};
1973 if (!fPdgNames || !pdg)
1974 return defaultname;
1975 for (Int_t i = 0; i < fNpdg; i++) {
1976 if (fPdgId[i] == pdg)
1977 return fPdgNames->At(i)->GetName();
1978 }
1979 return defaultname;
1980}
1981
1982////////////////////////////////////////////////////////////////////////////////
1983/// Set a name for a particle having a given pdg.
1984
1986{
1987 if (!pdg)
1988 return;
1989 if (!fPdgNames) {
1990 fPdgNames = new TObjArray(1024);
1991 }
1992 if (!strcmp(name, GetPdgName(pdg)))
1993 return;
1994 // store pdg name
1995 if (fNpdg > 1023) {
1996 Warning("SetPdgName", "No more than 256 different pdg codes allowed");
1997 return;
1998 }
1999 fPdgId[fNpdg] = pdg;
2000 TNamed *pdgname = new TNamed(name, "");
2002}
2003
2004////////////////////////////////////////////////////////////////////////////////
2005/// Get GDML matrix with a given name;
2006
2008{
2010}
2011
2012////////////////////////////////////////////////////////////////////////////////
2013/// Add GDML matrix;
2015{
2016 if (GetGDMLMatrix(mat->GetName())) {
2017 Error("AddGDMLMatrix", "Matrix %s already added to manager", mat->GetName());
2018 return;
2019 }
2021}
2022
2023////////////////////////////////////////////////////////////////////////////////
2024/// Get optical surface with a given name;
2025
2030
2031////////////////////////////////////////////////////////////////////////////////
2032/// Add optical surface;
2034{
2035 if (GetOpticalSurface(optsurf->GetName())) {
2036 Error("AddOpticalSurface", "Surface %s already added to manager", optsurf->GetName());
2037 return;
2038 }
2040}
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Get skin surface with a given name;
2044
2049
2050////////////////////////////////////////////////////////////////////////////////
2051/// Add skin surface;
2053{
2054 if (GetSkinSurface(surf->GetName())) {
2055 Error("AddSkinSurface", "Surface %s already added to manager", surf->GetName());
2056 return;
2057 }
2059}
2060
2061////////////////////////////////////////////////////////////////////////////////
2062/// Get border surface with a given name;
2063
2068
2069////////////////////////////////////////////////////////////////////////////////
2070/// Add border surface;
2072{
2073 if (GetBorderSurface(surf->GetName())) {
2074 Error("AddBorderSurface", "Surface %s already added to manager", surf->GetName());
2075 return;
2076 }
2078}
2079
2080////////////////////////////////////////////////////////////////////////////////
2081/// Fill node copy numbers of current branch into an array.
2082
2087
2088////////////////////////////////////////////////////////////////////////////////
2089/// Fill node copy numbers of current branch into an array.
2090
2095
2096////////////////////////////////////////////////////////////////////////////////
2097/// Retrieve cartesian and radial bomb factors.
2098
2100{
2101 if (fPainter) {
2103 return;
2104 }
2105 bombx = bomby = bombz = bombr = 1.3;
2106}
2107
2108////////////////////////////////////////////////////////////////////////////////
2109/// Return maximum number of daughters of a volume used in the geometry.
2110
2115
2116////////////////////////////////////////////////////////////////////////////////
2117/// Return maximum number of levels used in the geometry.
2118
2120{
2121 return fgMaxLevel;
2122}
2123
2124////////////////////////////////////////////////////////////////////////////////
2125/// Return maximum number of vertices for an xtru shape used.
2126
2131
2132////////////////////////////////////////////////////////////////////////////////
2133/// Returns number of threads that were set to use geometry.
2134
2139
2140////////////////////////////////////////////////////////////////////////////////
2141/// Return stored current matrix (global matrix of the next touched node).
2142
2144{
2145 if (!GetCurrentNavigator())
2146 return nullptr;
2147 return GetCurrentNavigator()->GetHMatrix();
2148}
2149
2150////////////////////////////////////////////////////////////////////////////////
2151/// Returns current depth to which geometry is drawn.
2152
2154{
2155 return fVisLevel;
2156}
2157
2158////////////////////////////////////////////////////////////////////////////////
2159/// Returns current depth to which geometry is drawn.
2160
2162{
2163 return fVisOption;
2164}
2165
2166////////////////////////////////////////////////////////////////////////////////
2167/// Find level of virtuality of current overlapping node (number of levels
2168/// up having the same tracking media.
2169
2174
2175////////////////////////////////////////////////////////////////////////////////
2176/// Search the track hierarchy to find the track with the
2177/// given id
2178///
2179/// if 'primsFirst' is true, then:
2180/// first tries TGeoManager::GetTrackOfId, then does a
2181/// recursive search if that fails. this would be faster
2182/// if the track is somehow known to be a primary
2183
2185{
2186 TVirtualGeoTrack *trk = nullptr;
2187 trk = GetTrackOfId(id);
2188 if (trk)
2189 return trk;
2190 // need recursive search
2191 TIter next(fTracks);
2193 while ((prim = (TVirtualGeoTrack *)next())) {
2194 trk = prim->FindTrackWithId(id);
2195 if (trk)
2196 return trk;
2197 }
2198 return nullptr;
2199}
2200
2201////////////////////////////////////////////////////////////////////////////////
2202/// Get track with a given ID.
2203
2205{
2207 for (Int_t i = 0; i < fNtracks; i++) {
2208 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2209 if (track->GetId() == id)
2210 return track;
2211 }
2212 }
2213 return nullptr;
2214}
2215
2216////////////////////////////////////////////////////////////////////////////////
2217/// Get parent track with a given ID.
2218
2220{
2222 while ((track = track->GetMother())) {
2223 if (track->GetId() == id)
2224 return track;
2225 }
2226 return nullptr;
2227}
2228
2229////////////////////////////////////////////////////////////////////////////////
2230/// Get index for track id, -1 if not found.
2231
2233{
2235 for (Int_t i = 0; i < fNtracks; i++) {
2236 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2237 if (track->GetId() == id)
2238 return i;
2239 }
2240 }
2241 return -1;
2242}
2243
2244////////////////////////////////////////////////////////////////////////////////
2245/// Go upwards the tree until a non-overlapping node
2246
2251
2252////////////////////////////////////////////////////////////////////////////////
2253/// Go upwards the tree until a non-overlapping node
2254
2259
2260////////////////////////////////////////////////////////////////////////////////
2261/// Set default volume colors according to A of material
2262
2264{
2265 const Int_t nmax = 110;
2266 Int_t col[nmax];
2267 for (Int_t i = 0; i < nmax; i++)
2268 col[i] = kGray;
2269
2270 // here we should create a new TColor with the same rgb as in the default
2271 // ROOT colors used below
2272 col[3] = kYellow - 10;
2273 col[4] = col[5] = kGreen - 10;
2274 col[6] = col[7] = kBlue - 7;
2275 col[8] = col[9] = kMagenta - 3;
2276 col[10] = col[11] = kRed - 10;
2277 col[12] = kGray + 1;
2278 col[13] = kBlue - 10;
2279 col[14] = kOrange + 7;
2280 col[16] = kYellow + 1;
2281 col[20] = kYellow - 10;
2282 col[24] = col[25] = col[26] = kBlue - 8;
2283 col[29] = kOrange + 9;
2284 col[79] = kOrange - 2;
2285
2286 TGeoVolume *vol;
2287 TIter next(fVolumes);
2288 while ((vol = (TGeoVolume *)next())) {
2289 TGeoMedium *med = vol->GetMedium();
2290 if (!med)
2291 continue;
2292 TGeoMaterial *mat = med->GetMaterial();
2293 Int_t matZ = (Int_t)mat->GetZ();
2294 vol->SetLineColor(col[matZ]);
2295 if (mat->GetDensity() < 0.1)
2296 vol->SetTransparency(60);
2297 }
2298}
2299
2300////////////////////////////////////////////////////////////////////////////////
2301/// Compute safe distance from the current point. This represent the distance
2302/// from POINT to the closest boundary.
2303
2305{
2306 return GetCurrentNavigator()->Safety(inside);
2307}
2308
2309////////////////////////////////////////////////////////////////////////////////
2310/// Set volume attributes in G3 style.
2311
2312void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2313{
2314 TGeoVolume *volume;
2315 Bool_t all = kFALSE;
2316 if (strstr(name, "*"))
2317 all = kTRUE;
2318 Int_t ivo = 0;
2319 TIter next(fVolumes);
2320 TString chatt = att;
2321 chatt.ToLower();
2322 while ((volume = (TGeoVolume *)next())) {
2323 if (strcmp(volume->GetName(), name) && !all)
2324 continue;
2325 ivo++;
2326 if (chatt.Contains("colo"))
2327 volume->SetLineColor(val);
2328 if (chatt.Contains("lsty"))
2329 volume->SetLineStyle(val);
2330 if (chatt.Contains("lwid"))
2331 volume->SetLineWidth(val);
2332 if (chatt.Contains("fill"))
2333 volume->SetFillColor(val);
2334 if (chatt.Contains("seen"))
2335 volume->SetVisibility(val);
2336 }
2338 while ((volume = (TGeoVolume *)next1())) {
2339 if (strcmp(volume->GetName(), name) && !all)
2340 continue;
2341 ivo++;
2342 if (chatt.Contains("colo"))
2343 volume->SetLineColor(val);
2344 if (chatt.Contains("lsty"))
2345 volume->SetLineStyle(val);
2346 if (chatt.Contains("lwid"))
2347 volume->SetLineWidth(val);
2348 if (chatt.Contains("fill"))
2349 volume->SetFillColor(val);
2350 if (chatt.Contains("seen"))
2351 volume->SetVisibility(val);
2352 }
2353 if (!ivo) {
2354 Warning("SetVolumeAttribute", "volume: %s does not exist", name);
2355 }
2356}
2357
2358////////////////////////////////////////////////////////////////////////////////
2359/// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2360
2366
2367////////////////////////////////////////////////////////////////////////////////
2368/// Set a user-defined shape as clipping for ray tracing.
2369
2371{
2373 if (shape) {
2374 if (fClippingShape && (fClippingShape != shape))
2376 fClippingShape = shape;
2377 }
2378 painter->SetClippingShape(shape);
2379}
2380
2381////////////////////////////////////////////////////////////////////////////////
2382/// set the maximum number of visible nodes.
2383
2385{
2387 if (maxnodes > 0 && fgVerboseLevel > 0)
2388 Info("SetMaxVisNodes", "Automatic visible depth for %d visible nodes", maxnodes);
2389 if (!fPainter)
2390 return;
2392 Int_t level = fPainter->GetVisLevel();
2393 if (level != fVisLevel)
2394 fVisLevel = level;
2395}
2396
2397////////////////////////////////////////////////////////////////////////////////
2398/// make top volume visible on screen
2399
2405
2406////////////////////////////////////////////////////////////////////////////////
2407/// Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
2408
2413
2414////////////////////////////////////////////////////////////////////////////////
2415/// Set the number of points to be generated on the shape outline when checking
2416/// for overlaps.
2417
2422
2423////////////////////////////////////////////////////////////////////////////////
2424/// set drawing mode :
2425/// - option=0 (default) all nodes drawn down to vislevel
2426/// - option=1 leaves and nodes at vislevel drawn
2427/// - option=2 path is drawn
2428/// - option=4 visibility changed
2429
2431{
2432 if ((option >= 0) && (option < 3))
2434 if (fPainter)
2436}
2437
2438////////////////////////////////////////////////////////////////////////////////
2439/// Set visualization option (leaves only OR all volumes)
2440
2442{
2443 if (flag)
2444 SetVisOption(1);
2445 else
2446 SetVisOption(0);
2447}
2448
2449////////////////////////////////////////////////////////////////////////////////
2450/// Set density threshold. Volumes with densities lower than this become
2451/// transparent.
2452
2459
2460////////////////////////////////////////////////////////////////////////////////
2461/// set default level down to which visualization is performed
2462
2464{
2465 if (level > 0) {
2466 fVisLevel = level;
2467 fMaxVisNodes = 0;
2468 if (fgVerboseLevel > 0)
2469 Info("SetVisLevel", "Automatic visible depth disabled");
2470 if (fPainter)
2472 } else {
2474 }
2475}
2476
2477////////////////////////////////////////////////////////////////////////////////
2478/// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2479
2481{
2482 fOverlaps->Sort();
2483}
2484
2485////////////////////////////////////////////////////////////////////////////////
2486/// Optimize voxelization type for all volumes. Save best choice in a macro.
2487
2489{
2490 if (!fTopNode) {
2491 Error("OptimizeVoxels", "Geometry must be closed first");
2492 return;
2493 }
2494 std::ofstream out;
2496 if (fname.IsNull())
2497 fname = "tgeovox.C";
2498 out.open(fname, std::ios::out);
2499 if (!out.good()) {
2500 Error("OptimizeVoxels", "cannot open file");
2501 return;
2502 }
2503 // write header
2504 TDatime t;
2506 sname.ReplaceAll(".C", "");
2507 out << sname.Data() << "()" << std::endl;
2508 out << "{" << std::endl;
2509 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2510 out << "//=== Voxel optimization for " << GetTitle() << " geometry" << std::endl;
2511 out << "//===== <run this macro JUST BEFORE closing the geometry>" << std::endl;
2512 out << " TGeoVolume *vol = 0;" << std::endl;
2513 out << " // parse all voxelized volumes" << std::endl;
2514 TGeoVolume *vol = nullptr;
2516 TIter next(fVolumes);
2517 while ((vol = (TGeoVolume *)next())) {
2518 if (!vol->GetVoxels())
2519 continue;
2520 out << " vol = gGeoManager->GetVolume(\"" << vol->GetName() << "\");" << std::endl;
2521 cyltype = vol->OptimizeVoxels();
2522 if (cyltype) {
2523 out << " vol->SetCylVoxels();" << std::endl;
2524 } else {
2525 out << " vol->SetCylVoxels(kFALSE);" << std::endl;
2526 }
2527 }
2528 out << "}" << std::endl;
2529 out.close();
2530}
2531////////////////////////////////////////////////////////////////////////////////
2532/// Parse a string boolean expression and do a syntax check. Find top
2533/// level boolean operator and returns its type. Fill the two
2534/// substrings to which this operator applies. The returned integer is :
2535/// - -1 : parse error
2536/// - 0 : no boolean operator
2537/// - 1 : union - represented as '+' in expression
2538/// - 2 : difference (subtraction) - represented as '-' in expression
2539/// - 3 : intersection - represented as '*' in expression.
2540/// Parentheses should be used to avoid ambiguities. For instance :
2541/// - A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2542/// eliminate not needed parentheses
2543
2545{
2547 Int_t len = startstr.Length();
2548 Int_t i;
2549 TString e0 = "";
2550 expr3 = "";
2551 // eliminate blanks
2552 for (i = 0; i < len; i++) {
2553 if (startstr(i) == ' ')
2554 continue;
2555 e0 += startstr(i, 1);
2556 }
2557 Int_t level = 0;
2558 Int_t levmin = 999;
2559 Int_t boolop = 0;
2560 Int_t indop = 0;
2561 Int_t iloop = 1;
2562 Int_t lastop = 0;
2563 Int_t lastdp = 0;
2564 Int_t lastpp = 0;
2566 // check/eliminate parentheses
2567 while (iloop == 1) {
2568 iloop = 0;
2569 lastop = 0;
2570 lastdp = 0;
2571 lastpp = 0;
2572 len = e0.Length();
2573 for (i = 0; i < len; i++) {
2574 if (e0(i) == '(') {
2575 if (!level)
2576 iloop++;
2577 level++;
2578 continue;
2579 }
2580 if (e0(i) == ')') {
2581 level--;
2582 if (level == 0)
2583 lastpp = i;
2584 continue;
2585 }
2586 if ((e0(i) == '+') || (e0(i) == '-') || (e0(i) == '*')) {
2587 lastop = i;
2588 if (level < levmin) {
2589 levmin = level;
2590 indop = i;
2591 }
2592 continue;
2593 }
2594 if ((e0(i) == ':') && (level == 0)) {
2595 lastdp = i;
2596 continue;
2597 }
2598 }
2599 if (level != 0) {
2600 if (gGeoManager)
2601 gGeoManager->Error("Parse", "parentheses does not match");
2602 return -1;
2603 }
2604 if (iloop == 1 && (e0(0) == '(') && (e0(len - 1) == ')')) {
2605 // eliminate extra parentheses
2606 e0 = e0(1, len - 2);
2607 continue;
2608 }
2609 if (foundmat)
2610 break;
2611 if (((lastop == 0) && (lastdp > 0)) || ((lastpp > 0) && (lastdp > lastpp) && (indop < lastpp))) {
2612 expr3 = e0(lastdp + 1, len - lastdp);
2613 e0 = e0(0, lastdp);
2614 foundmat = kTRUE;
2615 iloop = 1;
2616 continue;
2617 } else
2618 break;
2619 }
2620 // loop expression and search parentheses/operators
2621 levmin = 999;
2622 for (i = 0; i < len; i++) {
2623 if (e0(i) == '(') {
2624 level++;
2625 continue;
2626 }
2627 if (e0(i) == ')') {
2628 level--;
2629 continue;
2630 }
2631 // Take LAST operator at lowest level (revision 28/07/08)
2632 if (level <= levmin) {
2633 if (e0(i) == '+') {
2634 boolop = 1; // union
2635 levmin = level;
2636 indop = i;
2637 }
2638 if (e0(i) == '-') {
2639 boolop = 2; // difference
2640 levmin = level;
2641 indop = i;
2642 }
2643 if (e0(i) == '*') {
2644 boolop = 3; // intersection
2645 levmin = level;
2646 indop = i;
2647 }
2648 }
2649 }
2650 if (indop == 0) {
2651 expr1 = e0;
2652 return indop;
2653 }
2654 expr1 = e0(0, indop);
2655 expr2 = e0(indop + 1, len - indop);
2656 return boolop;
2657}
2658
2659////////////////////////////////////////////////////////////////////////////////
2660/// Save current attributes in a macro
2661
2663{
2664 if (!fTopNode) {
2665 Error("SaveAttributes", "geometry must be closed first\n");
2666 return;
2667 }
2668 std::ofstream out;
2670 if (fname.IsNull())
2671 fname = "tgeoatt.C";
2672 out.open(fname, std::ios::out);
2673 if (!out.good()) {
2674 Error("SaveAttributes", "cannot open file");
2675 return;
2676 }
2677 // write header
2678 TDatime t;
2680 sname.ReplaceAll(".C", "");
2681 out << sname.Data() << "()" << std::endl;
2682 out << "{" << std::endl;
2683 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2684 out << "//=== Attributes for " << GetTitle() << " geometry" << std::endl;
2685 out << "//===== <run this macro AFTER loading the geometry in memory>" << std::endl;
2686 // save current top volume
2687 out << " TGeoVolume *top = gGeoManager->GetVolume(\"" << fTopVolume->GetName() << "\");" << std::endl;
2688 out << " TGeoVolume *vol = 0;" << std::endl;
2689 out << " TGeoNode *node = 0;" << std::endl;
2690 out << " // clear all volume attributes and get painter" << std::endl;
2691 out << " gGeoManager->ClearAttributes();" << std::endl;
2692 out << " gGeoManager->GetGeomPainter();" << std::endl;
2693 out << " // set visualization modes and bomb factors" << std::endl;
2694 out << " gGeoManager->SetVisOption(" << GetVisOption() << ");" << std::endl;
2695 out << " gGeoManager->SetVisLevel(" << GetVisLevel() << ");" << std::endl;
2696 out << " gGeoManager->SetExplodedView(" << GetBombMode() << ");" << std::endl;
2699 out << " gGeoManager->SetBombFactors(" << bombx << "," << bomby << "," << bombz << "," << bombr << ");"
2700 << std::endl;
2701 out << " // iterate volumes container and set new attributes" << std::endl;
2702 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2703 TGeoVolume *vol = nullptr;
2705
2706 TIter next(fVolumes);
2707 while ((vol = (TGeoVolume *)next())) {
2708 vol->SetVisStreamed(kFALSE);
2709 }
2710 out << " // draw top volume with new settings" << std::endl;
2711 out << " top->Draw();" << std::endl;
2712 out << " gPad->x3d();" << std::endl;
2713 out << "}" << std::endl;
2714 out.close();
2715}
2716
2717////////////////////////////////////////////////////////////////////////////////
2718/// Returns the deepest node containing fPoint, which must be set a priori.
2719
2724
2725////////////////////////////////////////////////////////////////////////////////
2726/// Cross next boundary and locate within current node
2727/// The current point must be on the boundary of fCurrentNode.
2728
2733
2734////////////////////////////////////////////////////////////////////////////////
2735/// Compute distance to next boundary within STEPMAX. If no boundary is found,
2736/// propagate current point along current direction with fStep=STEPMAX. Otherwise
2737/// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2738/// node.
2739
2744
2745////////////////////////////////////////////////////////////////////////////////
2746/// Find distance to next boundary and store it in fStep. Returns node to which this
2747/// boundary belongs. If PATH is specified, compute only distance to the node to which
2748/// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2749/// than this value. STEPMAX represent the step to be made imposed by other reasons than
2750/// geometry (usually physics processes). Therefore in this case this method provides the
2751/// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2752/// fStep with a big number.
2753/// In case frombdr=kTRUE, the isotropic safety is set to zero.
2754///
2755/// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2756/// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2757/// they want this computed for the current point.
2758
2760{
2761 // convert current point and direction to local reference
2763}
2764
2765////////////////////////////////////////////////////////////////////////////////
2766/// Computes as fStep the distance to next daughter of the current volume.
2767/// The point and direction must be converted in the coordinate system of the current volume.
2768/// The proposed step limit is fStep.
2769
2774
2775////////////////////////////////////////////////////////////////////////////////
2776/// Reset current state flags.
2777
2782
2783////////////////////////////////////////////////////////////////////////////////
2784/// Returns deepest node containing current point.
2785
2790
2791////////////////////////////////////////////////////////////////////////////////
2792/// Returns deepest node containing current point.
2793
2798
2799////////////////////////////////////////////////////////////////////////////////
2800/// Computes fast normal to next crossed boundary, assuming that the current point
2801/// is close enough to the boundary. Works only after calling FindNextBoundary.
2802
2807
2808////////////////////////////////////////////////////////////////////////////////
2809/// Computes normal vector to the next surface that will be or was already
2810/// crossed when propagating on a straight line from a given point/direction.
2811/// Returns the normal vector cosines in the MASTER coordinate system. The dot
2812/// product of the normal and the current direction is positive defined.
2813
2815{
2816 return GetCurrentNavigator()->FindNormal(forward);
2817}
2818
2819////////////////////////////////////////////////////////////////////////////////
2820/// Checks if point (x,y,z) is still in the current node.
2821
2826
2827////////////////////////////////////////////////////////////////////////////////
2828/// Check if a new point with given coordinates is the same as the last located one.
2829
2834
2835////////////////////////////////////////////////////////////////////////////////
2836/// True if current node is in phi range
2837
2839{
2840 if (!fPhiCut)
2841 return kTRUE;
2842 const Double_t *origin;
2844 return kFALSE;
2845 origin = ((TGeoBBox *)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2846 Double_t point[3];
2847 LocalToMaster(origin, &point[0]);
2848 Double_t phi = TMath::ATan2(point[1], point[0]) * TMath::RadToDeg();
2849 if (phi < 0)
2850 phi += 360.;
2851 if ((phi >= fPhimin) && (phi <= fPhimax))
2852 return kFALSE;
2853 return kTRUE;
2854}
2855
2856////////////////////////////////////////////////////////////////////////////////
2857/// Initialize current point and current direction vector (normalized)
2858/// in MARS. Return corresponding node.
2859
2861{
2862 return GetCurrentNavigator()->InitTrack(point, dir);
2863}
2864
2865////////////////////////////////////////////////////////////////////////////////
2866/// Initialize current point and current direction vector (normalized)
2867/// in MARS. Return corresponding node.
2868
2873
2874////////////////////////////////////////////////////////////////////////////////
2875/// Inspects path and all flags for the current state.
2876
2881
2882////////////////////////////////////////////////////////////////////////////////
2883/// Get path to the current node in the form /node0/node1/...
2884
2885const char *TGeoManager::GetPath() const
2886{
2887 return GetCurrentNavigator()->GetPath();
2888}
2889
2890////////////////////////////////////////////////////////////////////////////////
2891/// Get total size of geometry in bytes.
2892
2894{
2895 Int_t count = 0;
2896 TIter next(fVolumes);
2897 TGeoVolume *vol;
2898 while ((vol = (TGeoVolume *)next()))
2899 count += vol->GetByteCount();
2902 while ((matrix = (TGeoMatrix *)next1()))
2903 count += matrix->GetByteCount();
2906 while ((mat = (TGeoMaterial *)next2()))
2907 count += mat->GetByteCount();
2909 TGeoMedium *med;
2910 while ((med = (TGeoMedium *)next3()))
2911 count += med->GetByteCount();
2912 if (fgVerboseLevel > 0)
2913 Info("GetByteCount", "Total size of logical tree : %i bytes", count);
2914 return count;
2915}
2916
2917////////////////////////////////////////////////////////////////////////////////
2918/// Make a default painter if none present. Returns pointer to it.
2919
2921{
2922 if (!fPainter) {
2923 const char *kind = nullptr;
2924 if (gPad)
2925 kind = gPad->IsWeb() ? "web" : "root";
2926 else
2927 kind = gEnv->GetValue("GeomPainter.Name", "");
2928
2929 if (!kind || !*kind)
2930 kind = (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch()) ? "web" : "root";
2931
2932 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter", kind)) {
2933 if (h->LoadPlugin() == -1) {
2934 Error("GetGeomPainter", "could not load plugin for %s geo_painter", kind);
2935 return nullptr;
2936 }
2937 fPainter = (TVirtualGeoPainter *)h->ExecPlugin(1, this);
2938 if (!fPainter) {
2939 Error("GetGeomPainter", "could not create %s geo_painter", kind);
2940 return nullptr;
2941 }
2942 } else {
2943 Error("GetGeomPainter", "not found plugin %s for geo_painter", kind);
2944 }
2945 }
2946 return fPainter;
2947}
2948
2949////////////////////////////////////////////////////////////////////////////////
2950/// Make a default checker if none present. Returns pointer to it.
2951
2953{
2954 if (!fChecker) {
2955 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoChecker", "root")) {
2956 if (h->LoadPlugin() == -1) {
2957 Error("GetGeomChecker", "could not load plugin for geo_checker");
2958 return nullptr;
2959 }
2960 fChecker = (TVirtualGeoChecker *)h->ExecPlugin(1, this);
2961 if (!fChecker) {
2962 Error("GetGeomChecker", "could not create geo_checker");
2963 return nullptr;
2964 }
2965 } else {
2966 Error("GetGeomChecker", "not found plugin for geo_checker");
2967 }
2968 }
2969 return fChecker;
2970}
2971
2972////////////////////////////////////////////////////////////////////////////////
2973/// Search for a named volume. All trailing blanks stripped.
2974
2976{
2977 TString sname = name;
2978 sname = sname.Strip();
2979 TGeoVolume *vol = (TGeoVolume *)fVolumes->FindObject(sname.Data());
2980 return vol;
2981}
2982
2983////////////////////////////////////////////////////////////////////////////////
2984/// Fast search for a named volume. All trailing blanks stripped.
2985
2987{
2988 if (!fHashVolumes) {
2991 fHashVolumes = new THashList(nvol + 1);
2992 fHashGVolumes = new THashList(ngvol + 1);
2993 Int_t i;
2994 for (i = 0; i < ngvol; i++)
2996 for (i = 0; i < nvol; i++)
2998 }
2999 TString sname = name;
3000 sname = sname.Strip();
3001 THashList *list = fHashVolumes;
3002 if (multi)
3003 list = fHashGVolumes;
3004 TGeoVolume *vol = (TGeoVolume *)list->FindObject(sname.Data());
3005 return vol;
3006}
3007
3008////////////////////////////////////////////////////////////////////////////////
3009/// Retrieve unique id for a volume name. Return -1 if name not found.
3010
3012{
3013 TGeoManager *geom = (TGeoManager *)this;
3014 TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
3015 if (!vol)
3016 vol = geom->FindVolumeFast(volname, kTRUE);
3017 if (!vol)
3018 return -1;
3019 return vol->GetNumber();
3020}
3021
3022////////////////////////////////////////////////////////////////////////////////
3023/// Find if a given material duplicates an existing one.
3024
3026{
3028 if (index <= 0)
3029 return nullptr;
3031 for (Int_t i = 0; i < index; i++) {
3033 if (other == mat)
3034 continue;
3035 if (other->IsEq(mat))
3036 return other;
3037 }
3038 return nullptr;
3039}
3040
3041////////////////////////////////////////////////////////////////////////////////
3042/// Search for a named material. All trailing blanks stripped.
3043
3045{
3047 sname = sname.Strip();
3049 return mat;
3050}
3051
3052////////////////////////////////////////////////////////////////////////////////
3053/// Search for a named tracking medium. All trailing blanks stripped.
3054
3056{
3058 sname = sname.Strip();
3060 return med;
3061}
3062
3063////////////////////////////////////////////////////////////////////////////////
3064/// Search for a tracking medium with a given ID.
3065
3067{
3068 TIter next(fMedia);
3069 TGeoMedium *med;
3070 while ((med = (TGeoMedium *)next())) {
3071 if (med->GetId() == numed)
3072 return med;
3073 }
3074 return nullptr;
3075}
3076
3077////////////////////////////////////////////////////////////////////////////////
3078/// Return material at position id.
3079
3081{
3083 return nullptr;
3085 return mat;
3086}
3087
3088////////////////////////////////////////////////////////////////////////////////
3089/// Return index of named material.
3090
3092{
3093 TIter next(fMaterials);
3095 Int_t id = 0;
3097 sname = sname.Strip();
3098 while ((mat = (TGeoMaterial *)next())) {
3099 if (!strcmp(mat->GetName(), sname.Data()))
3100 return id;
3101 id++;
3102 }
3103 return -1; // fail
3104}
3105
3106////////////////////////////////////////////////////////////////////////////////
3107/// Randomly shoot nrays and plot intersections with surfaces for current
3108/// top node.
3109
3115
3116////////////////////////////////////////////////////////////////////////////////
3117/// Remove material at given index.
3118
3120{
3121 TObject *obj = fMaterials->At(index);
3122 if (obj)
3123 fMaterials->Remove(obj);
3124}
3125
3126////////////////////////////////////////////////////////////////////////////////
3127/// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
3128/// from geometry. Deletion has to be managed by users.
3129
3131{
3132 TIter next(fVolumes);
3133 TGeoVolume *vol;
3134 while ((vol = (TGeoVolume *)next()))
3135 vol->SetField(nullptr);
3136}
3137
3138////////////////////////////////////////////////////////////////////////////////
3139/// Change raytracing mode.
3140
3147
3148////////////////////////////////////////////////////////////////////////////////
3149/// Restore the master volume of the geometry.
3150
3152{
3154 return;
3155 if (fMasterVolume)
3157}
3158
3159////////////////////////////////////////////////////////////////////////////////
3160/// Voxelize all non-divided volumes.
3161
3163{
3164 TGeoVolume *vol;
3165 // TGeoVoxelFinder *vox = 0;
3166 if (!fStreamVoxels && fgVerboseLevel > 0)
3167 Info("Voxelize", "Voxelizing...");
3168 // Int_t nentries = fVolumes->GetSize();
3169 TIter next(fVolumes);
3170 while ((vol = (TGeoVolume *)next())) {
3171 if (!fIsGeomReading)
3172 vol->SortNodes();
3173 if (!fStreamVoxels) {
3174 vol->Voxelize(option);
3175 }
3176 if (!fIsGeomReading)
3177 vol->FindOverlaps();
3178 }
3179}
3180
3181////////////////////////////////////////////////////////////////////////////////
3182/// Send "Modified" signal to painter.
3183
3185{
3186 if (!fPainter)
3187 return;
3189}
3190
3191////////////////////////////////////////////////////////////////////////////////
3192/// Make an TGeoArb8 volume.
3193
3195{
3196 return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
3197}
3198
3199////////////////////////////////////////////////////////////////////////////////
3200/// Make in one step a volume pointing to a box shape with given medium.
3201
3206
3207////////////////////////////////////////////////////////////////////////////////
3208/// Make in one step a volume pointing to a parallelepiped shape with given medium.
3209
3211 Double_t alpha, Double_t theta, Double_t phi)
3212{
3213 return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
3214}
3215
3216////////////////////////////////////////////////////////////////////////////////
3217/// Make in one step a volume pointing to a sphere shape with given medium
3218
3224
3225////////////////////////////////////////////////////////////////////////////////
3226/// Make in one step a volume pointing to a torus shape with given medium.
3227
3233
3234////////////////////////////////////////////////////////////////////////////////
3235/// Make in one step a volume pointing to a tube shape with given medium.
3236
3241
3242////////////////////////////////////////////////////////////////////////////////
3243/// Make in one step a volume pointing to a tube segment shape with given medium.
3244/// The segment will be from phiStart to phiEnd, the angles are expressed in degree
3245
3251
3252////////////////////////////////////////////////////////////////////////////////
3253/// Make in one step a volume pointing to a tube shape with given medium
3254
3256{
3257 return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
3258}
3259
3260////////////////////////////////////////////////////////////////////////////////
3261/// Make in one step a volume pointing to a tube shape with given medium
3262
3268
3269////////////////////////////////////////////////////////////////////////////////
3270/// Make in one step a volume pointing to a tube shape with given medium
3271
3276
3277////////////////////////////////////////////////////////////////////////////////
3278/// Make in one step a volume pointing to a tube segment shape with given medium
3279
3286
3287////////////////////////////////////////////////////////////////////////////////
3288/// Make in one step a volume pointing to a cone shape with given medium.
3289
3295
3296////////////////////////////////////////////////////////////////////////////////
3297/// Make in one step a volume pointing to a cone segment shape with given medium
3298
3304
3305////////////////////////////////////////////////////////////////////////////////
3306/// Make in one step a volume pointing to a polycone shape with given medium.
3307
3309{
3310 return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3311}
3312
3313////////////////////////////////////////////////////////////////////////////////
3314/// Make in one step a volume pointing to a polygone shape with given medium.
3315
3316TGeoVolume *
3318{
3319 return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3320}
3321
3322////////////////////////////////////////////////////////////////////////////////
3323/// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3324
3325TGeoVolume *
3330
3331////////////////////////////////////////////////////////////////////////////////
3332/// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3333
3339
3340////////////////////////////////////////////////////////////////////////////////
3341/// Make in one step a volume pointing to a trapezoid shape with given medium.
3342
3346{
3347 return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2,
3348 alpha2);
3349}
3350
3351////////////////////////////////////////////////////////////////////////////////
3352/// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3353
3361
3362////////////////////////////////////////////////////////////////////////////////
3363/// Make a TGeoXtru-shaped volume with nz planes
3364
3366{
3367 return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3368}
3369
3370////////////////////////////////////////////////////////////////////////////////
3371/// Creates an alignable object with unique name corresponding to a path
3372/// and adds it to the list of alignables. An optional unique ID can be
3373/// provided, in which case PN entries can be searched fast by uid.
3374
3376{
3377 if (!CheckPath(path))
3378 return nullptr;
3379 if (!fHashPNE)
3380 fHashPNE = new THashList(256, 3);
3381 if (!fArrayPNE)
3382 fArrayPNE = new TObjArray(256);
3384 if (entry) {
3385 Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3386 return nullptr;
3387 }
3388 entry = new TGeoPNEntry(unique_name, path);
3390 fHashPNE->Add(entry);
3392 if (uid >= 0) {
3394 if (!added)
3395 Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3396 }
3397 return entry;
3398}
3399
3400////////////////////////////////////////////////////////////////////////////////
3401/// Retrieves an existing alignable object.
3402
3404{
3405 if (!fHashPNE)
3406 return nullptr;
3407 return (TGeoPNEntry *)fHashPNE->FindObject(name);
3408}
3409
3410////////////////////////////////////////////////////////////////////////////////
3411/// Retrieves an existing alignable object at a given index.
3412
3414{
3415 if (!fArrayPNE && !InitArrayPNE())
3416 return nullptr;
3417 return (TGeoPNEntry *)fArrayPNE->At(index);
3418}
3419
3420////////////////////////////////////////////////////////////////////////////////
3421/// Retrieves an existing alignable object having a preset UID.
3422
3424{
3425 if (!fNPNEId || (!fArrayPNE && !InitArrayPNE()))
3426 return nullptr;
3428 if (index < 0 || fKeyPNEId[index] != uid)
3429 return nullptr;
3431}
3432
3433////////////////////////////////////////////////////////////////////////////////
3434/// Retrieves number of PN entries with or without UID.
3435
3437{
3438 if (!fHashPNE)
3439 return 0;
3440 if (with_uid)
3441 return fNPNEId;
3442 return fHashPNE->GetSize();
3443}
3444
3445////////////////////////////////////////////////////////////////////////////////
3446/// Insert a PN entry in the sorted array of indexes.
3447
3449{
3450 if (!fSizePNEId) {
3451 // Create the arrays.
3452 fSizePNEId = 128;
3453 fKeyPNEId = new Int_t[fSizePNEId];
3454 memset(fKeyPNEId, 0, fSizePNEId * sizeof(Int_t));
3456 memset(fValuePNEId, 0, fSizePNEId * sizeof(Int_t));
3457 fKeyPNEId[fNPNEId] = uid;
3459 return kTRUE;
3460 }
3461 // Search id in the existing array and return false if it already exists.
3463 if (index > 0 && fKeyPNEId[index] == uid)
3464 return kFALSE;
3465 // Resize the arrays and insert the value
3466 Bool_t resize = (fNPNEId == fSizePNEId) ? kTRUE : kFALSE;
3467 if (resize) {
3468 // Double the size of the array
3469 fSizePNEId *= 2;
3470 // Create new arrays of keys and values
3471 Int_t *keys = new Int_t[fSizePNEId];
3472 memset(keys, 0, fSizePNEId * sizeof(Int_t));
3473 Int_t *values = new Int_t[fSizePNEId];
3474 memset(values, 0, fSizePNEId * sizeof(Int_t));
3475 // Copy all keys<uid in the new keys array (0 to index)
3476 memcpy(keys, fKeyPNEId, (index + 1) * sizeof(Int_t));
3477 memcpy(values, fValuePNEId, (index + 1) * sizeof(Int_t));
3478 // Insert current key at index+1
3479 keys[index + 1] = uid;
3480 values[index + 1] = ientry;
3481 // Copy all remaining keys from the old to new array
3482 memcpy(&keys[index + 2], &fKeyPNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3483 memcpy(&values[index + 2], &fValuePNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3484 delete[] fKeyPNEId;
3485 fKeyPNEId = keys;
3486 delete[] fValuePNEId;
3487 fValuePNEId = values;
3488 fNPNEId++;
3489 return kTRUE;
3490 }
3491 // Insert the value in the existing arrays
3492 Int_t i;
3493 for (i = fNPNEId - 1; i > index; i--) {
3494 fKeyPNEId[i + 1] = fKeyPNEId[i];
3495 fValuePNEId[i + 1] = fValuePNEId[i];
3496 }
3497 fKeyPNEId[index + 1] = uid;
3498 fValuePNEId[index + 1] = ientry;
3499 fNPNEId++;
3500 return kTRUE;
3501}
3502
3503////////////////////////////////////////////////////////////////////////////////
3504/// Make a physical node from the path pointed by an alignable object with a given name.
3505
3507{
3509 if (!entry) {
3510 Error("MakeAlignablePN", "No alignable object named %s found !", name);
3511 return nullptr;
3512 }
3513 return MakeAlignablePN(entry);
3514}
3515
3516////////////////////////////////////////////////////////////////////////////////
3517/// Make a physical node from the path pointed by a given alignable object.
3518
3520{
3521 if (!entry) {
3522 Error("MakeAlignablePN", "No alignable object specified !");
3523 return nullptr;
3524 }
3525 const char *path = entry->GetTitle();
3526 if (!cd(path)) {
3527 Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s", entry->GetName(), path);
3528 return nullptr;
3529 }
3530 TGeoPhysicalNode *node = MakePhysicalNode(path);
3531 entry->SetPhysicalNode(node);
3532 return node;
3533}
3534
3535////////////////////////////////////////////////////////////////////////////////
3536/// Makes a physical node corresponding to a path. If PATH is not specified,
3537/// makes physical node matching current modeller state.
3538
3540{
3541 TGeoPhysicalNode *node;
3542 if (path) {
3543 if (!CheckPath(path)) {
3544 Error("MakePhysicalNode", "path: %s not valid", path);
3545 return nullptr;
3546 }
3547 node = new TGeoPhysicalNode(path);
3548 } else {
3549 node = new TGeoPhysicalNode(GetPath());
3550 }
3551 fPhysicalNodes->Add(node);
3552 return node;
3553}
3554
3555////////////////////////////////////////////////////////////////////////////////
3556/// Refresh physical nodes to reflect the actual geometry paths after alignment
3557/// was applied. Optionally locks physical nodes (default).
3558
3560{
3563 while ((pn = (TGeoPhysicalNode *)next()))
3564 pn->Refresh();
3567 if (lock)
3568 LockGeometry();
3569}
3570
3571////////////////////////////////////////////////////////////////////////////////
3572/// Clear the current list of physical nodes, so that we can start over with a new list.
3573/// If MUSTDELETE is true, delete previous nodes.
3574
3582
3583////////////////////////////////////////////////////////////////////////////////
3584/// Make an assembly of volumes.
3585
3587{
3588 return TGeoBuilder::Instance(this)->MakeVolumeAssembly(name);
3589}
3590
3591////////////////////////////////////////////////////////////////////////////////
3592/// Make a TGeoVolumeMulti handling a list of volumes.
3593
3595{
3596 return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3597}
3598
3599////////////////////////////////////////////////////////////////////////////////
3600/// Set type of exploding view (see TGeoPainter::SetExplodedView())
3601
3603{
3604 if ((ibomb >= 0) && (ibomb < 4))
3606 if (fPainter)
3608}
3609
3610////////////////////////////////////////////////////////////////////////////////
3611/// Set cut phi range
3612
3614{
3615 if ((phimin == 0) && (phimax == 360)) {
3616 fPhiCut = kFALSE;
3617 return;
3618 }
3619 fPhiCut = kTRUE;
3620 fPhimin = phimin;
3621 fPhimax = phimax;
3622}
3623
3624////////////////////////////////////////////////////////////////////////////////
3625/// Set number of segments for approximating circles in drawing.
3626
3628{
3629 if (fNsegments == nseg)
3630 return;
3631 if (nseg > 2)
3632 fNsegments = nseg;
3633 if (fPainter)
3635}
3636
3637////////////////////////////////////////////////////////////////////////////////
3638/// Get number of segments approximating circles
3639
3641{
3642 return fNsegments;
3643}
3644
3645////////////////////////////////////////////////////////////////////////////////
3646/// Now just a shortcut for GetElementTable.
3647
3653
3654////////////////////////////////////////////////////////////////////////////////
3655/// Returns material table. Creates it if not existing.
3656
3663
3664////////////////////////////////////////////////////////////////////////////////
3665/// Make a rectilinear step of length fStep from current point (fPoint) on current
3666/// direction (fDirection). If the step is imposed by geometry, is_geom flag
3667/// must be true (default). The cross flag specifies if the boundary should be
3668/// crossed in case of a geometry step (default true). Returns new node after step.
3669/// Set also on boundary condition.
3670
3672{
3673 return GetCurrentNavigator()->Step(is_geom, cross);
3674}
3675
3676////////////////////////////////////////////////////////////////////////////////
3677/// shoot npoints randomly in a box of 1E-5 around current point.
3678/// return minimum distance to points outside
3679
3684
3685////////////////////////////////////////////////////////////////////////////////
3686/// Set the top volume and corresponding node as starting point of the geometry.
3687
3689{
3690 if (fTopVolume == vol)
3691 return;
3692
3693 TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3694 TIter next(brlist);
3695 TBrowser *browser = nullptr;
3696
3697 if (fTopVolume)
3698 fTopVolume->SetTitle("");
3699 fTopVolume = vol;
3700 vol->SetTitle("Top volume");
3701 if (fTopNode) {
3703 fTopNode = nullptr;
3704 while ((browser = (TBrowser *)next()))
3705 browser->RecursiveRemove(topn);
3706 delete topn;
3707 } else {
3708 fMasterVolume = vol;
3711 if (fgVerboseLevel > 0)
3712 Info("SetTopVolume", "Top volume is %s. Master volume is %s", fTopVolume->GetName(), fMasterVolume->GetName());
3713 }
3714 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3715 // fCurrentMatrix->Print();
3717 fTopNode->SetName(TString::Format("%s_1", vol->GetName()));
3718 fTopNode->SetNumber(1);
3719 fTopNode->SetTitle("Top logical node");
3720 fNodes->AddAt(fTopNode, 0);
3721 if (!GetCurrentNavigator()) {
3723 return;
3724 }
3725 Int_t nnavigators = 0;
3727 if (!arr)
3728 return;
3729 nnavigators = arr->GetEntriesFast();
3730 for (Int_t i = 0; i < nnavigators; i++) {
3731 TGeoNavigator *nav = (TGeoNavigator *)arr->At(i);
3732 nav->ResetAll();
3733 if (fClosed)
3734 nav->GetCache()->BuildInfoBranch();
3735 }
3736}
3737
3738////////////////////////////////////////////////////////////////////////////////
3739/// Define different tracking media.
3740
3742{
3743 /*
3744 Int_t nmat = fMaterials->GetSize();
3745 if (!nmat) {printf(" No materials !\n"); return;}
3746 Int_t *media = new Int_t[nmat];
3747 memset(media, 0, nmat*sizeof(Int_t));
3748 Int_t imedia = 1;
3749 TGeoMaterial *mat, *matref;
3750 mat = (TGeoMaterial*)fMaterials->At(0);
3751 if (mat->GetMedia()) {
3752 for (Int_t i=0; i<nmat; i++) {
3753 mat = (TGeoMaterial*)fMaterials->At(i);
3754 mat->Print();
3755 }
3756 return;
3757 }
3758 mat->SetMedia(imedia);
3759 media[0] = imedia++;
3760 mat->Print();
3761 for (Int_t i=0; i<nmat; i++) {
3762 mat = (TGeoMaterial*)fMaterials->At(i);
3763 for (Int_t j=0; j<i; j++) {
3764 matref = (TGeoMaterial*)fMaterials->At(j);
3765 if (mat->IsEq(matref)) {
3766 mat->SetMedia(media[j]);
3767 break;
3768 }
3769 if (j==(i-1)) {
3770 // different material
3771 mat->SetMedia(imedia);
3772 media[i] = imedia++;
3773 mat->Print();
3774 }
3775 }
3776 }
3777 */
3778}
3779
3780////////////////////////////////////////////////////////////////////////////////
3781/// Check pushes and pulls needed to cross the next boundary with respect to the
3782/// position given by FindNextBoundary. If radius is not mentioned the full bounding
3783/// box will be sampled.
3784
3789
3790////////////////////////////////////////////////////////////////////////////////
3791/// Check the boundary errors reference file created by CheckBoundaryErrors method.
3792/// The shape for which the crossing failed is drawn with the starting point in red
3793/// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3794
3799
3800////////////////////////////////////////////////////////////////////////////////
3801/// Classify a given point. See TGeoChecker::CheckPoint().
3802
3807
3808////////////////////////////////////////////////////////////////////////////////
3809/// Test for shape navigation methods. Summary for test numbers:
3810/// - 1: DistFromInside/Outside. Sample points inside the shape. Generate
3811/// directions randomly in cos(theta). Compute DistFromInside and move the
3812/// point with bigger distance. Compute DistFromOutside back from new point.
3813/// Plot d-(d1+d2)
3814///
3815
3820
3821////////////////////////////////////////////////////////////////////////////////
3822/// Geometry checking.
3823/// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3824/// - if option contains 'b': Optional boundary crossing check + timing per volume.
3825///
3826/// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3827/// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3828/// be called for the suspicious volumes.
3829///
3830/// STAGE 2: normal overlap checking using the shapes mesh - fills the list of
3831/// overlaps.
3832///
3833/// STAGE 3: shooting NRAYS rays from VERTEX and counting the total number of
3834/// crossings per volume (rays propagated from boundary to boundary until
3835/// geometry exit). Timing computed and results stored in a histo.
3836///
3837/// STAGE 4: shooting 1 mil. random rays inside EACH volume and calling
3838/// FindNextBoundary() + Safety() for each call. The timing is normalized by the
3839/// number of crossings computed at stage 2 and presented as percentage.
3840/// One can get a picture on which are the most "burned" volumes during
3841/// transportation from geometry point of view. Another plot of the timing per
3842/// volume vs. number of daughters is produced.
3843
3845{
3846 TString opt(option);
3847 opt.ToLower();
3848 if (!opt.Length()) {
3849 Error("CheckGeometryFull", "The option string must contain a letter. See method documentation.");
3850 return;
3851 }
3852 Bool_t checkoverlaps = opt.Contains("o");
3853 Bool_t checkcrossings = opt.Contains("b");
3854 Double_t vertex[3];
3855 vertex[0] = vx;
3856 vertex[1] = vy;
3857 vertex[2] = vz;
3859}
3860
3861////////////////////////////////////////////////////////////////////////////////
3862/// Perform last checks on the geometry
3863
3865{
3866 if (fgVerboseLevel > 0)
3867 Info("CheckGeometry", "Fixing runtime shapes...");
3868 TIter next(fShapes);
3870 TGeoShape *shape;
3871 TGeoVolume *vol;
3873 while ((shape = (TGeoShape *)next())) {
3874 if (shape->IsRunTimeShape()) {
3876 }
3877 if (fIsGeomReading)
3878 shape->AfterStreamer();
3881 shape->ComputeBBox();
3882 }
3883 if (has_runtime)
3885 else if (fgVerboseLevel > 0)
3886 Info("CheckGeometry", "...Nothing to fix");
3887 // Compute bounding box for assemblies
3889 while ((vol = (TGeoVolume *)nextv())) {
3890 if (vol->IsAssembly())
3891 vol->GetShape()->ComputeBBox();
3892 else if (vol->GetMedium() == dummy) {
3893 Warning("CheckGeometry", "Volume \"%s\" has no medium: assigned dummy medium and material", vol->GetName());
3894 vol->SetMedium(dummy);
3895 }
3896 }
3897}
3898
3899////////////////////////////////////////////////////////////////////////////////
3900/// Check all geometry for illegal overlaps within a limit OVLP.
3901
3903{
3904 if (!fTopNode) {
3905 Error("CheckOverlaps", "Top node not set");
3906 return;
3907 }
3909}
3910
3911////////////////////////////////////////////////////////////////////////////////
3912/// Prints the current list of overlaps.
3913
3915{
3916 if (!fOverlaps)
3917 return;
3919 if (!novlp)
3920 return;
3921 TGeoManager *geom = (TGeoManager *)this;
3922 geom->GetGeomChecker()->PrintOverlaps();
3923}
3924
3925////////////////////////////////////////////////////////////////////////////////
3926/// Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
3927/// Option can be "v" - verbose (default)
3928
3930{
3931 if (!GetGeomChecker())
3932 return 0.;
3933 TString opt(option);
3934 opt.ToLower();
3935 Double_t weight;
3936 TGeoVolume *volume = fTopVolume;
3937 if (opt.Contains("v")) {
3938 if (opt.Contains("a")) {
3939 if (fgVerboseLevel > 0)
3940 Info("Weight", "Computing analytically weight of %s", volume->GetName());
3941 weight = volume->WeightA();
3942 if (fgVerboseLevel > 0)
3943 Info("Weight", "Computed weight: %f [kg]\n", weight);
3944 return weight;
3945 }
3946 if (fgVerboseLevel > 0) {
3947 Info("Weight", "Estimating weight of %s with %g %% precision", fTopVolume->GetName(), 100. * precision);
3948 printf(" event weight err\n");
3949 printf("========================================\n");
3950 }
3951 }
3952 weight = fChecker->Weight(precision, option);
3953 return weight;
3954}
3955
3956////////////////////////////////////////////////////////////////////////////////
3957/// computes the total size in bytes of the branch starting with node.
3958/// The option can specify if all the branch has to be parsed or only the node
3959
3960ULong_t TGeoManager::SizeOf(const TGeoNode * /*node*/, Option_t * /*option*/)
3961{
3962 return 0;
3963}
3964
3965////////////////////////////////////////////////////////////////////////////////
3966/// Stream an object of class TGeoManager.
3967
3969{
3970 if (R__b.IsReading()) {
3971 R__b.ReadClassBuffer(TGeoManager::Class(), this);
3973 CloseGeometry();
3976 } else {
3977 R__b.WriteClassBuffer(TGeoManager::Class(), this);
3978 }
3979}
3980
3981////////////////////////////////////////////////////////////////////////////////
3982/// Execute mouse actions on this manager.
3983
3985{
3986 if (!fPainter)
3987 return;
3988 fPainter->ExecuteManagerEvent(this, event, px, py);
3989}
3990
3991////////////////////////////////////////////////////////////////////////////////
3992/// Export this geometry to a file
3993///
3994/// - Case 1: root file or root/xml file
3995/// if filename end with ".root". The key will be named name
3996/// By default the geometry is saved without the voxelisation info.
3997/// Use option 'v" to save the voxelisation info.
3998/// if filename end with ".xml" a root/xml file is produced.
3999///
4000/// - Case 2: C++ script
4001/// if filename end with ".C"
4002///
4003/// - Case 3: gdml file
4004/// if filename end with ".gdml"
4005/// NOTE that to use this option, the PYTHONPATH must be defined like
4006/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/geom/gdml
4007///
4008
4010{
4012 if (sfile.Contains(".C")) {
4013 // Save geometry as a C++ script
4014 if (fgVerboseLevel > 0)
4015 Info("Export", "Exporting %s %s as C++ code", GetName(), GetTitle());
4017 return 1;
4018 }
4019 if (sfile.Contains(".gdml")) {
4020 // Save geometry as a gdml file
4021 if (fgVerboseLevel > 0)
4022 Info("Export", "Exporting %s %s as gdml code", GetName(), GetTitle());
4023 // C++ version
4024 TString cmd;
4025 cmd = TString::Format("TGDMLWrite::StartGDMLWriting(gGeoManager,\"%s\",\"%s\")", filename, option);
4026 gROOT->ProcessLineFast(cmd);
4027 return 1;
4028 }
4029 if (sfile.Contains(".root") || sfile.Contains(".xml")) {
4030 // Save geometry as a root file
4031 TFile *f = TFile::Open(filename, "recreate");
4032 if (!f || f->IsZombie()) {
4033 Error("Export", "Cannot open file");
4034 return 0;
4035 }
4037 if (keyname.IsNull())
4038 keyname = GetName();
4039 TString opt = option;
4040 opt.ToLower();
4041 if (opt.Contains("v")) {
4043 if (fgVerboseLevel > 0)
4044 Info("Export", "Exporting %s %s as root file. Optimizations streamed.", GetName(), GetTitle());
4045 } else {
4047 if (fgVerboseLevel > 0)
4048 Info("Export", "Exporting %s %s as root file. Optimizations not streamed.", GetName(), GetTitle());
4049 }
4050
4054 if (sfile.Contains(".xml")) {
4057 }
4059 if (sfile.Contains(".xml")) {
4062 }
4063
4065 delete f;
4066 return nbytes;
4067 }
4068 return 0;
4069}
4070
4071////////////////////////////////////////////////////////////////////////////////
4072/// Lock current geometry so that no other geometry can be imported.
4073
4075{
4076 fgLock = kTRUE;
4077}
4078
4079////////////////////////////////////////////////////////////////////////////////
4080/// Unlock current geometry.
4081
4083{
4084 fgLock = kFALSE;
4085}
4086
4087////////////////////////////////////////////////////////////////////////////////
4088/// Check lock state.
4089
4091{
4092 return fgLock;
4093}
4094
4095////////////////////////////////////////////////////////////////////////////////
4096/// Set verbosity level (static function).
4097/// - 0 - suppress messages related to geom-painter visibility level
4098/// - 1 - default value
4099
4104
4105////////////////////////////////////////////////////////////////////////////////
4106/// Return current verbosity level (static function).
4107
4112
4113////////////////////////////////////////////////////////////////////////////////
4114/// static function
4115/// Import a geometry from a gdml or ROOT file
4116///
4117/// - Case 1: gdml
4118/// if filename ends with ".gdml" the foreign geometry described with gdml
4119/// is imported executing some python scripts in $ROOTSYS/gdml.
4120/// NOTE that to use this option, the PYTHONPATH must be defined like
4121/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
4122///
4123/// - Case 2: root file (.root) or root/xml file (.xml)
4124/// Import in memory from filename the geometry with key=name.
4125/// if name="" (default), the first TGeoManager object in the file is returned.
4126///
4127/// Note that this function deletes the current gGeoManager (if one)
4128/// before importing the new object.
4129
4130TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
4131{
4132 if (fgLock) {
4133 ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
4134 return nullptr;
4135 }
4136 if (!filename)
4137 return nullptr;
4138 if (fgVerboseLevel > 0)
4139 ::Info("TGeoManager::Import", "Reading geometry from file: %s", filename);
4140
4141 if (gGeoManager)
4142 delete gGeoManager;
4143 gGeoManager = nullptr;
4144
4145 if (strstr(filename, ".gdml")) {
4146 // import from a gdml file
4147 new TGeoManager("GDMLImport", "Geometry imported from GDML");
4148 TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
4149 TGeoVolume *world = (TGeoVolume *)gROOT->ProcessLineFast(cmd);
4150
4151 if (world == nullptr) {
4152 delete gGeoManager;
4153 gGeoManager = nullptr;
4154 ::Error("TGeoManager::Import", "Cannot read file %s", filename);
4155 } else {
4159 }
4160 } else {
4161 // import from a root file
4163 // in case a web file is specified, use the cacheread option to cache
4164 // this file in the cache directory
4165 TFile *f = nullptr;
4166 if (strstr(filename, "http"))
4167 f = TFile::Open(filename, "CACHEREAD");
4168 else
4170 if (!f || f->IsZombie()) {
4171 ::Error("TGeoManager::Import", "Cannot open file");
4172 return nullptr;
4173 }
4174 if (name && strlen(name) > 0) {
4175 gGeoManager = (TGeoManager *)f->Get(name);
4176 } else {
4177 TIter next(f->GetListOfKeys());
4178 TKey *key;
4179 while ((key = (TKey *)next())) {
4180 if (strcmp(key->GetClassName(), "TGeoManager") != 0)
4181 continue;
4182 gGeoManager = (TGeoManager *)key->ReadObj();
4183 break;
4184 }
4185 }
4186 delete f;
4187 }
4188 if (!gGeoManager)
4189 return nullptr;
4190 if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager))
4191 gROOT->GetListOfGeometries()->Add(gGeoManager);
4192 if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager))
4193 gROOT->GetListOfBrowsables()->Add(gGeoManager);
4195 return gGeoManager;
4196}
4197
4198////////////////////////////////////////////////////////////////////////////////
4199/// Update element flags when geometry is loaded from a file.
4200
4202{
4203 if (!fElementTable)
4204 return;
4205 TIter next(fMaterials);
4207 TGeoMixture *mix;
4209 Int_t i, nelem;
4210 while ((mat = (TGeoMaterial *)next())) {
4211 if (mat->IsMixture()) {
4212 mix = (TGeoMixture *)mat;
4213 nelem = mix->GetNelements();
4214 for (i = 0; i < nelem; i++) {
4215 elem = mix->GetElement(i);
4216 if (!elem)
4217 continue;
4219 if (!elem_table)
4220 continue;
4221 if (elem != elem_table) {
4222 elem_table->SetDefined(elem->IsDefined());
4223 elem_table->SetUsed(elem->IsUsed());
4224 } else {
4225 elem_table->SetDefined();
4226 }
4227 }
4228 } else {
4229 elem = mat->GetElement();
4230 if (!elem)
4231 continue;
4233 if (!elem_table)
4234 continue;
4235 if (elem != elem_table) {
4236 elem_table->SetDefined(elem->IsDefined());
4237 elem_table->SetUsed(elem->IsUsed());
4238 } else {
4239 elem_table->SetUsed();
4240 }
4241 }
4242 }
4243}
4244
4245////////////////////////////////////////////////////////////////////////////////
4246/// Initialize PNE array for fast access via index and unique-id.
4247
4249{
4250 if (fHashPNE) {
4252 TIter next(fHashPNE);
4253 TObject *obj;
4254 while ((obj = next())) {
4255 fArrayPNE->Add(obj);
4256 }
4257 return kTRUE;
4258 }
4259 return kFALSE;
4260}
4261
4262////////////////////////////////////////////////////////////////////////////////
4263/// Get time cut for drawing tracks.
4264
4266{
4267 tmin = fTmin;
4268 tmax = fTmax;
4269 return fTimeCut;
4270}
4271
4272////////////////////////////////////////////////////////////////////////////////
4273/// Set time cut interval for drawing tracks. If called with no arguments, time
4274/// cut will be disabled.
4275
4277{
4278 fTmin = tmin;
4279 fTmax = tmax;
4280 if (tmin == 0 && tmax == 999)
4281 fTimeCut = kFALSE;
4282 else
4283 fTimeCut = kTRUE;
4284 if (fTracks && !IsAnimatingTracks())
4285 ModifiedPad();
4286}
4287
4288////////////////////////////////////////////////////////////////////////////////
4289/// Convert coordinates from master volume frame to top.
4290
4295
4296////////////////////////////////////////////////////////////////////////////////
4297/// Convert coordinates from top volume frame to master.
4298
4303
4304////////////////////////////////////////////////////////////////////////////////
4305/// Create a parallel world for prioritised navigation. This can be populated
4306/// with physical nodes and can be navigated independently using its API.
4307/// In case the flag SetUseParallelWorldNav is set, any navigation query in the
4308/// main geometry is checked against the parallel geometry, which gets priority
4309/// in case of overlaps with the main geometry volumes.
4310
4316
4317////////////////////////////////////////////////////////////////////////////////
4318/// Activate/deactivate usage of parallel world navigation. Can only be done if
4319/// there is a parallel world. Activating navigation will automatically close
4320/// the parallel geometry.
4321
4323{
4324 if (!fParallelWorld) {
4325 Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
4326 return;
4327 }
4328 if (!flag) {
4329 fUsePWNav = flag;
4330 return;
4331 }
4332 if (!fClosed) {
4333 Error("SetUseParallelWorldNav", "The geometry must be closed first");
4334 return;
4335 }
4336 // Closing the parallel world geometry is mandatory
4338 fUsePWNav = kTRUE;
4339}
4340
4347
4352
4354{
4355 if (fgDefaultUnits == new_value) {
4356 gGeometryLocked = true;
4357 return;
4358 } else if (gGeometryLocked) {
4359 ::Fatal("TGeoManager", "The system of units may only be changed once, \n"
4360 "BEFORE any elements and materials are created! \n"
4361 "Alternatively unlock the default units at own risk.");
4362 } else if (new_value == kG4Units) {
4363 ::Info("TGeoManager", "Changing system of units to Geant4 units (mm, ns, MeV).");
4364 } else if (new_value == kRootUnits) {
4365 ::Info("TGeoManager", "Changing system of units to ROOT units (cm, s, GeV).");
4366 }
4368}
4369
4374
#define SafeDelete(p)
Definition RConfig.hxx:533
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned char UChar_t
Definition RtypesCore.h:38
unsigned long ULong_t
Definition RtypesCore.h:55
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassImp(name)
Definition Rtypes.h:374
@ kGray
Definition Rtypes.h:65
@ kRed
Definition Rtypes.h:66
@ kOrange
Definition Rtypes.h:67
@ kGreen
Definition Rtypes.h:66
@ kMagenta
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
char name[80]
Definition TGX11.cxx:110
TGeoManager * gGeoManager
static Bool_t gGeometryLocked
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TGeoIdentity * gGeoIdentity
Definition TGeoMatrix.h:537
int nentries
#define gROOT
Definition TROOT.h:414
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define gPad
const_iterator end() const
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
static const char * GetFloatFormat()
return current printf format for float members, default "%e"
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e" to change format only for doubles,...
static const char * GetDoubleFormat()
return current printf format for double members, default "%.14e"
static void SetDoubleFormat(const char *fmt="%.14e")
set printf format for double members, default "%.14e" use it after SetFloatFormat,...
Buffer base class used for serializing objects.
Definition TBuffer.h:43
@ kRealNew
Definition TClass.h:110
@ kDummyNew
Definition TClass.h:110
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition TClass.cxx:6045
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition TDatime.cxx:102
TDirectory::TContext keeps track and restore the current directory.
Definition TDirectory.h:89
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4116
This class is used in the process of reading and writing the GDML "matrix" tag.
Definition TGDMLMatrix.h:33
Bool_t IsVisTouched() const
Definition TGeoAtt.h:91
void SetVisStreamed(Bool_t vis=kTRUE)
Mark attributes as "streamed to file".
Definition TGeoAtt.cxx:128
void SetVisTouched(Bool_t vis=kTRUE)
Mark visualization attributes as "modified".
Definition TGeoAtt.cxx:138
void SetVisBranch()
Set branch type visibility.
Definition TGeoAtt.cxx:66
Box class.
Definition TGeoBBox.h:17
static TGeoBuilder * Instance(TGeoManager *geom)
Return pointer to singleton.
Class describing rotation + translation.
Definition TGeoMatrix.h:317
Composite shapes are Boolean combinations of two or more shape components.
table of elements
TGeoElement * GetElement(Int_t z)
Base class for chemical elements.
Definition TGeoElement.h:31
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition TGeoMatrix.h:458
An identity transformation.
Definition TGeoMatrix.h:406
A geometry iterator.
Definition TGeoNode.h:248
Int_t GetLevel() const
Definition TGeoNode.h:294
The manager class for any TGeo geometry.
Definition TGeoManager.h:45
static void UnlockGeometry()
Unlock current geometry.
Double_t fPhimax
lowest range for phi cut
Definition TGeoManager.h:64
TGeoVolume * MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
Make in one step a volume pointing to a cone shape with given medium.
void AnimateTracks(Double_t tmin=0, Double_t tmax=5E-8, Int_t nframes=200, Option_t *option="/*")
Draw animation of tracks.
void AddSkinSurface(TGeoSkinSurface *surf)
Add skin surface;.
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
TGeoVolume * MakePcon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nz)
Make in one step a volume pointing to a polycone shape with given medium.
Int_t fRaytraceMode
Flag for multi-threading.
Double_t fVisDensity
particles to be drawn
Definition TGeoManager.h:70
TGeoNavigator * AddNavigator()
Add a navigator in the list of navigators.
TVirtualGeoTrack * GetTrackOfId(Int_t id) const
Get track with a given ID.
TGeoMaterial * FindDuplicateMaterial(const TGeoMaterial *mat) const
Find if a given material duplicates an existing one.
TGeoVolume * Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Create a new volume by dividing an existing one (GEANT3 like)
TGeoVolume * Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar=0)
Create a volume in GEANT3 style.
Int_t ReplaceVolume(TGeoVolume *vorig, TGeoVolume *vnew)
Replaces all occurrences of VORIG with VNEW in the geometry tree.
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
Int_t GetCurrentNodeId() const
Get the unique ID of the current node.
TGeoPNEntry * GetAlignableEntry(const char *name) const
Retrieves an existing alignable object.
TGeoVolume * fMasterVolume
top physical node
TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Search the track hierarchy to find the track with the given id.
TObjArray * fArrayPNE
void TestOverlaps(const char *path="")
Geometry overlap checker based on sampling.
static EDefaultUnits GetDefaultUnits()
void RemoveMaterial(Int_t index)
Remove material at given index.
void Matrix(Int_t index, Double_t theta1, Double_t phi1, Double_t theta2, Double_t phi2, Double_t theta3, Double_t phi3)
Create rotation matrix named 'mat<index>'.
TGeoElementTable * GetElementTable()
Returns material table. Creates it if not existing.
Int_t fNtracks
Definition TGeoManager.h:75
THashList * fHashPNE
hash list of group volumes providing fast search
static Int_t fgVerboseLevel
Lock preventing a second geometry to be loaded.
Definition TGeoManager.h:52
void Init()
Initialize manager class.
Bool_t InitArrayPNE() const
Initialize PNE array for fast access via index and unique-id.
TObjArray * fPhysicalNodes
Definition TGeoManager.h:98
virtual ULong_t SizeOf(const TGeoNode *node, Option_t *option)
computes the total size in bytes of the branch starting with node.
TObjArray * fUniqueVolumes
static UInt_t fgExportPrecision
Maximum number of Xtru vertices.
Definition TGeoManager.h:56
TObjArray * fRegions
void Node(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, Bool_t isOnly, Float_t *upar, Int_t npar=0)
Create a node called <name_nr> pointing to the volume called <name> as daughter of the volume called ...
TObjArray * fGShapes
Definition TGeoManager.h:99
TGeoVolume * fPaintVolume
TGeoSkinSurface * GetSkinSurface(const char *name) const
Get skin surface with a given name;.
void UpdateElements()
Update element flags when geometry is loaded from a file.
TGeoManager()
Default constructor.
TVirtualGeoChecker * GetGeomChecker()
Make a default checker if none present. Returns pointer to it.
static TClass * Class()
ConstPropMap_t fProperties
TGeoVolume * MakeTube(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
void CdUp()
Go one level up in geometry.
void DoBackupState()
Backup the current state without affecting the cache stack.
TList * fMaterials
void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)
Check pushes and pulls needed to cross the next boundary with respect to the position given by FindNe...
TObjArray * fVolumes
Definition TGeoManager.h:97
Int_t * fValuePNEId
TGeoPNEntry * GetAlignableEntryByUID(Int_t uid) const
Retrieves an existing alignable object having a preset UID.
void AddGDMLMatrix(TGDMLMatrix *mat)
Add GDML matrix;.
Bool_t fTimeCut
Definition TGeoManager.h:86
static void SetExportPrecision(UInt_t prec)
void AddBorderSurface(TGeoBorderSurface *surf)
Add border surface;.
void SetClippingShape(TGeoShape *clip)
Set a user-defined shape as clipping for ray tracing.
TGeoVolume * fCurrentVolume
current navigator
void ClearOverlaps()
Clear the list of overlaps.
TGeoVolume * MakeCons(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a cone segment shape with given medium.
THashList * fHashGVolumes
hash list of volumes providing fast search
TVirtualGeoChecker * fChecker
current painter
Definition TGeoManager.h:93
Int_t fVisOption
Definition TGeoManager.h:72
static std::mutex fgMutex
Definition TGeoManager.h:50
Bool_t IsInPhiRange() const
True if current node is in phi range.
virtual Bool_t cd(const char *path="")
Browse the tree of nodes starting from fTopNode according to pathname.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=nullptr)
Returns the deepest node containing fPoint, which must be set a priori.
TGeoMaterial * Material(const char *name, Double_t a, Double_t z, Double_t dens, Int_t uid, Double_t radlen=0, Double_t intlen=0)
Create material with given A, Z and density, having an unique id.
void LocalToMaster(const Double_t *local, Double_t *master) const
Double_t fPhimin
Definition TGeoManager.h:63
static Bool_t fgLockNavigators
Number of registered threads.
void SaveAttributes(const char *filename="tgeoatt.C")
Save current attributes in a macro.
void RestoreMasterVolume()
Restore the master volume of the geometry.
Bool_t fDrawExtra
Definition TGeoManager.h:87
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=nullptr)
Make an TGeoArb8 volume.
virtual Int_t Export(const char *filename, const char *name="", Option_t *option="vg")
Export this geometry to a file.
TGeoNode * FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE)
Computes as fStep the distance to next daughter of the current volume.
Int_t GetUID(const char *volname) const
Retrieve unique id for a volume name. Return -1 if name not found.
TGeoShape * fClippingShape
TGeoNavigator * GetCurrentNavigator() const
Returns current navigator for the calling thread.
THashList * fHashVolumes
TObjArray * fMatrices
current checker
Definition TGeoManager.h:95
static Int_t GetNumThreads()
Returns number of threads that were set to use geometry.
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
void ClearNavigators()
Clear all navigators.
Int_t AddTransformation(const TGeoMatrix *matrix)
Add a matrix to the list. Returns index of the matrix in list.
TObjArray * fOpticalSurfaces
TVirtualGeoTrack * GetParentTrackOfId(Int_t id) const
Get parent track with a given ID.
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
UChar_t * fBits
static Int_t GetMaxLevels()
Return maximum number of levels used in the geometry.
Double_t fTmin
highest range for phi cut
Definition TGeoManager.h:65
static Bool_t IsLocked()
Check lock state.
TGeoVolume * fTopVolume
current volume
TGeoVolume * fUserPaintVolume
volume currently painted
TVirtualGeoPainter * GetGeomPainter()
Make a default painter if none present. Returns pointer to it.
void GetBranchOnlys(Int_t *isonly) const
Fill node copy numbers of current branch into an array.
TGeoNode * GetCurrentNode() const
Int_t AddTrack(Int_t id, Int_t pdgcode, TObject *particle=nullptr)
Add a track to the list of tracks.
void SetVisOption(Int_t option=0)
set drawing mode :
void SetPdgName(Int_t pdg, const char *name)
Set a name for a particle having a given pdg.
TObjArray * fBorderSurfaces
Int_t GetNAlignable(Bool_t with_uid=kFALSE) const
Retrieves number of PN entries with or without UID.
void RefreshPhysicalNodes(Bool_t lock=kTRUE)
Refresh physical nodes to reflect the actual geometry paths after alignment was applied.
static Bool_t fgLock
mutex for navigator booking in MT mode
Definition TGeoManager.h:51
TGeoVolume * MakePara(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz, Double_t alpha, Double_t theta, Double_t phi)
Make in one step a volume pointing to a parallelepiped shape with given medium.
void TopToMaster(const Double_t *top, Double_t *master) const
Convert coordinates from top volume frame to master.
TObjArray * fShapes
Definition TGeoManager.h:96
void AddOpticalSurface(TGeoOpticalSurface *optsurf)
Add optical surface;.
static void SetDefaultUnits(EDefaultUnits new_value)
Bool_t fLoopVolumes
flag that geometry is closed
Definition TGeoManager.h:81
Int_t AddMaterial(const TGeoMaterial *material)
Add a material to the list. Returns index of the material in list.
void ClearAttributes()
Reset all attributes to default ones.
static Int_t fgMaxDaughters
Maximum level in geometry.
Definition TGeoManager.h:54
Bool_t fUsePWNav
Raytrace mode: 0=normal, 1=pass through, 2=transparent.
void SetRTmode(Int_t mode)
Change raytracing mode.
Bool_t CheckPath(const char *path) const
Check if a geometry path is valid without changing the state of the current navigator.
void InspectState() const
Inspects path and all flags for the current state.
void ConvertReflections()
Convert all reflections in geometry to normal rotations + reflected shapes.
void SetVisLevel(Int_t level=3)
set default level down to which visualization is performed
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
TGeoPhysicalNode * MakePhysicalNode(const char *path=nullptr)
Makes a physical node corresponding to a path.
void CountLevels()
Count maximum number of nodes per volume, maximum depth and maximum number of xtru vertices.
Int_t fMaxThreads
Bool_t fIsGeomReading
Definition TGeoManager.h:83
TGeoVolume * MakeTorus(const char *name, TGeoMedium *medium, Double_t r, Double_t rmin, Double_t rmax, Double_t phi1=0, Double_t dphi=360)
Make in one step a volume pointing to a torus shape with given medium.
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
TGeoParallelWorld * fParallelWorld
void RegisterMatrix(const TGeoMatrix *matrix)
Register a matrix to the list of matrices.
TVirtualGeoTrack * GetTrack(Int_t index)
static Int_t GetMaxDaughters()
Return maximum number of daughters of a volume used in the geometry.
static void ClearThreadsMap()
Clear the current map of threads.
Int_t AddVolume(TGeoVolume *volume)
Add a volume to the list. Returns index of the volume in list.
TVirtualGeoPainter * fPainter
flag that nodes are the selected objects in pad rather than volumes
Definition TGeoManager.h:92
void SetVolumeAttribute(const char *name, const char *att, Int_t val)
Set volume attributes in G3 style.
const char * GetPdgName(Int_t pdg) const
Get name for given pdg code;.
void CheckGeometryFull(Int_t ntracks=1000000, Double_t vx=0., Double_t vy=0., Double_t vz=0., Option_t *option="ob")
Geometry checking.
Bool_t fIsNodeSelectable
switch ON/OFF volume activity (default OFF - all volumes active))
Definition TGeoManager.h:91
TGeoNode * Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)
Make a rectilinear step of length fStep from current point (fPoint) on current direction (fDirection)...
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
Bool_t fActivity
flag for GL reflections
Definition TGeoManager.h:90
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
static ThreadsMap_t * fgThreadId
Map between thread id's and navigator arrays.
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TVirtualGeoTrack * MakeTrack(Int_t id, Int_t pdgcode, TObject *particle)
Makes a primary track but do not attach it to the list of tracks.
Int_t GetTrackIndex(Int_t id) const
Get index for track id, -1 if not found.
Int_t fNNodes
upper time limit for tracks drawing
Definition TGeoManager.h:67
Int_t fNLevel
table of elements
void OptimizeVoxels(const char *filename="tgeovox.C")
Optimize voxelization type for all volumes. Save best choice in a macro.
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
void SetAnimateTracks(Bool_t flag=kTRUE)
Bool_t fIsGeomCleaning
flag set when reading geometry
Definition TGeoManager.h:84
Bool_t IsSameLocation() const
void DefaultColors()
Set default volume colors according to A of material.
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
TGeoVolume * MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz)
Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
Double_t * FindNormal(Bool_t forward=kTRUE)
Computes normal vector to the next surface that will be or was already crossed when propagating on a ...
virtual Int_t GetByteCount(Option_t *option=nullptr)
Get total size of geometry in bytes.
TGeoVolume * MakeGtra(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a twisted trapezoid shape with given medium.
TGeoElementTable * fElementTable
clipping shape for raytracing
static void SetNavigatorsLock(Bool_t flag)
Set the lock for navigators.
static Int_t fgMaxXtruVert
Maximum number of daughters.
Definition TGeoManager.h:55
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
Int_t GetVisOption() const
Returns current depth to which geometry is drawn.
static void LockGeometry()
Lock current geometry so that no other geometry can be imported.
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)
Test for shape navigation methods.
static Int_t fgMaxLevel
Verbosity level for Info messages (no IO).
Definition TGeoManager.h:53
Int_t fNpdg
current track
Definition TGeoManager.h:78
void PrintOverlaps() const
Prints the current list of overlaps.
TGeoVolume * MakeTrd1(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy, Double_t dz)
Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
TGeoVolume * MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin=0, Double_t themax=180, Double_t phimin=0, Double_t phimax=360)
Make in one step a volume pointing to a sphere shape with given medium.
void ResetUserData()
Sets all pointers TGeoVolume::fField to NULL.
TGeoVolume * FindVolumeFast(const char *name, Bool_t multi=kFALSE)
Fast search for a named volume. All trailing blanks stripped.
TList * fMedia
Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const
Get time cut for drawing tracks.
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
ThreadsMap_t::const_iterator ThreadsMapIt_t
Bool_t fMatrixTransform
flag that the list of physical nodes has to be drawn
Definition TGeoManager.h:88
void SetVisibility(TObject *obj, Bool_t vis)
Set visibility for a volume.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Bool_t fMatrixReflection
flag for using GL matrix
Definition TGeoManager.h:89
TGeoPNEntry * SetAlignableEntry(const char *unique_name, const char *path, Int_t uid=-1)
Creates an alignable object with unique name corresponding to a path and adds it to the list of align...
void ClearShape(const TGeoShape *shape)
Remove a shape from the list of shapes.
void ModifiedPad() const
Send "Modified" signal to painter.
void BombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new 'bombed' translation vector according current exploded view mode.
TGeoNavigator * fCurrentNavigator
Lock existing navigators.
static Bool_t LockDefaultUnits(Bool_t new_value)
Int_t fMaxVisNodes
Definition TGeoManager.h:76
TGeoMedium * GetMedium(const char *medium) const
Search for a named tracking medium. All trailing blanks stripped.
Bool_t InsertPNEId(Int_t uid, Int_t ientry)
Insert a PN entry in the sorted array of indexes.
Int_t fVisLevel
Definition TGeoManager.h:73
void ViewLeaves(Bool_t flag=kTRUE)
Set visualization option (leaves only OR all volumes)
TGeoVolume * MakeCtub(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
Make in one step a volume pointing to a tube segment shape with given medium.
void SetTminTmax(Double_t tmin=0, Double_t tmax=999)
Set time cut interval for drawing tracks.
NavigatorsMap_t fNavigators
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
Bool_t fPhiCut
flag to notify that the manager is being destructed
Definition TGeoManager.h:85
TGeoNode * CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode)
Cross next boundary and locate within current node The current point must be on the boundary of fCurr...
void DrawTracks(Option_t *option="")
Draw tracks over the geometry, according to option.
void Streamer(TBuffer &) override
Stream an object of class TGeoManager.
void BuildDefaultMaterials()
Now just a shortcut for GetElementTable.
void SetMaxThreads(Int_t nthreads)
Set maximum number of threads for navigation.
TGeoMedium * Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
Create tracking medium.
void SetExplodedView(Int_t iopt=0)
Set type of exploding view (see TGeoPainter::SetExplodedView())
Double_t Weight(Double_t precision=0.01, Option_t *option="va")
Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
void ClearPhysicalNodes(Bool_t mustdelete=kFALSE)
Clear the current list of physical nodes, so that we can start over with a new list.
static Int_t Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
Parse a string boolean expression and do a syntax check.
void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
Retrieve cartesian and radial bomb factors.
Double_t GetProperty(const char *name, Bool_t *error=nullptr) const
Get a user-defined property.
TObjArray * fTracks
list of runtime volumes
Bool_t IsAnimatingTracks() const
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
static Int_t fgNumThreads
Thread id's map.
TObjArray * fGDMLMatrices
TGeoPhysicalNode * MakeAlignablePN(const char *name)
Make a physical node from the path pointed by an alignable object with a given name.
void SetCheckedNode(TGeoNode *node)
Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
Int_t AddOverlap(const TNamed *ovlp)
Add an illegal overlap/extrusion to the list.
void CreateThreadData() const
Create thread private data for all geometry objects.
Int_t fNsegments
Definition TGeoManager.h:74
TObjArray * fOverlaps
TGeoNode * SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil=1E-5, const char *g3path="")
shoot npoints randomly in a box of 1E-5 around current point.
Bool_t IsMultiThread() const
TGDMLMatrix * GetGDMLMatrix(const char *name) const
Get GDML matrix with a given name;.
Double_t fTmax
lower time limit for tracks drawing
Definition TGeoManager.h:66
Int_t TransformVolumeToAssembly(const char *vname)
Transform all volumes named VNAME to assemblies. The volumes must be virtual.
Bool_t fMultiThread
Max number of threads.
TGeoVolume * MakePgon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
Make in one step a volume pointing to a polygone shape with given medium.
TGeoVolume * MakeTrap(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a trapezoid shape with given medium.
void DrawCurrentPoint(Int_t color=2)
Draw current point in the same view.
static void SetVerboseLevel(Int_t vl)
Return current verbosity level (static function).
TGeoOpticalSurface * GetOpticalSurface(const char *name) const
Get optical surface with a given name;.
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
static UInt_t GetExportPrecision()
Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const
Check if a new point with given coordinates is the same as the last located one.
void SetNmeshPoints(Int_t npoints=1000)
Set the number of points to be generated on the shape outline when checking for overlaps.
void CheckBoundaryReference(Int_t icheck=-1)
Check the boundary errors reference file created by CheckBoundaryErrors method.
static Int_t GetVerboseLevel()
Set verbosity level (static function).
Int_t GetVisLevel() const
Returns current depth to which geometry is drawn.
static EDefaultUnits fgDefaultUnits
Precision to be used in ASCII exports.
Definition TGeoManager.h:57
virtual void Edit(Option_t *option="")
Append a pad for this geometry.
Bool_t AddProperty(const char *property, Double_t value)
Add a user-defined property. Returns true if added, false if existing.
~TGeoManager() override
Destructor.
TObjArray * fNodes
Int_t CountNodes(const TGeoVolume *vol=nullptr, Int_t nlevels=10000, Int_t option=0)
Count the total number of nodes starting from a volume, nlevels down.
TGeoMaterial * GetMaterial(const char *matname) const
Search for a named material. All trailing blanks stripped.
void CheckGeometry(Option_t *option="")
Perform last checks on the geometry.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute mouse actions on this manager.
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
Make an assembly of volumes.
Int_t GetBombMode() const
Int_t AddRegion(TGeoRegion *region)
Add a new region of volumes.
void SelectTrackingMedia()
Define different tracking media.
void CdNext()
Do a cd to the node found next by FindNextBoundary.
void CdTop()
Make top level node the current node.
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
Int_t * fKeyPNEId
void DefaultAngles()
Set default angles for a given view.
TGeoMaterial * Mixture(const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nelem, Float_t *wmat, Int_t uid)
Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem materials defined by arrays A,...
std::map< std::thread::id, Int_t > ThreadsMap_t
void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="", Double_t safety=0.)
Classify a given point. See TGeoChecker::CheckPoint().
void SetUseParallelWorldNav(Bool_t flag)
Activate/deactivate usage of parallel world navigation.
void Browse(TBrowser *b) override
Describe how to browse this object.
void Test(Int_t npoints=1000000, Option_t *option="")
Check time of finding "Where am I" for n points.
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
TObjArray * fGVolumes
list of runtime shapes
void SetBombFactors(Double_t bombx=1.3, Double_t bomby=1.3, Double_t bombz=1.3, Double_t bombr=1.3)
Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
TGeoNode * fTopNode
top level volume in geometry
void UnbombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new 'unbombed' translation vector according current exploded view mode.
void ResetState()
Reset current state flags.
void RandomPoints(const TGeoVolume *vol, Int_t npoints=10000, Option_t *option="")
Draw random points in the bounding box of a volume.
TGeoParallelWorld * CreateParallelWorld(const char *name)
Create a parallel world for prioritised navigation.
Int_t GetMaterialIndex(const char *matname) const
Return index of named material.
void CdDown(Int_t index)
Make a daughter of current node current.
TGeoNavigatorArray * GetListOfNavigators() const
Get list of navigators for the calling thread.
static Int_t GetMaxXtruVert()
Return maximum number of vertices for an xtru shape used.
void RandomRays(Int_t nrays=1000, Double_t startx=0, Double_t starty=0, Double_t startz=0, const char *target_vol=nullptr, Bool_t check_norm=kFALSE)
Randomly shoot nrays and plot intersections with surfaces for current top node.
void SetAllIndex()
Assigns uid's for all materials,media and matrices.
TObjArray * fSkinSurfaces
void SetVisDensity(Double_t dens=0.01)
Set density threshold.
Int_t fExplodedView
Definition TGeoManager.h:71
Bool_t fClosed
Definition TGeoManager.h:80
Int_t GetNsegments() const
Get number of segments approximating circles.
void SetPhiRange(Double_t phimin=0., Double_t phimax=360.)
Set cut phi range.
TGeoHMatrix * fGLMatrix
TVirtualGeoTrack * fCurrentTrack
Definition TGeoManager.h:77
TObjArray * fPdgNames
void DrawPath(const char *path, Option_t *option="")
Draw current path.
TObjArray * GetListOfPhysicalNodes()
static Int_t ThreadId()
Translates the current thread id to an ordinal number.
Bool_t SetCurrentNavigator(Int_t index)
Switch to another existing navigator for the calling thread.
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
TGeoVolume * MakeHype(const char *name, TGeoMedium *medium, Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeParaboloid(const char *name, TGeoMedium *medium, Double_t rlo, Double_t rhi, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
Int_t AddShape(const TGeoShape *shape)
Add a shape to the list. Returns index of the shape in list.
void SetMaxVisNodes(Int_t maxnodes=10000)
set the maximum number of visible nodes.
void CleanGarbage()
Clean temporary volumes and shapes from garbage collection.
void Voxelize(Option_t *option=nullptr)
Voxelize all non-divided volumes.
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
TGeoBorderSurface * GetBorderSurface(const char *name) const
Get border surface with a given name;.
void ClearThreadData() const
Int_t fSizePNEId
array of physical node entries
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check all geometry for illegal overlaps within a limit OVLP.
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
Int_t fPdgId[1024]
Definition TGeoManager.h:79
void SortOverlaps()
Sort overlaps by decreasing overlap distance. Extrusions comes first.
TGeoVolume * MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
void RemoveNavigator(const TGeoNavigator *nav)
Clear a single navigator.
void MasterToTop(const Double_t *master, Double_t *top) const
Convert coordinates from master volume frame to top.
Bool_t fStreamVoxels
flag volume lists loop
Definition TGeoManager.h:82
Base class describing materials.
Geometrical transformation package.
Definition TGeoMatrix.h:38
@ kGeoSavePrimitive
Definition TGeoMatrix.h:48
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
@ kMedSavePrimitive
Definition TGeoMedium.h:25
Mixtures of elements.
Int_t GetNelements() const override
TGeoElement * GetElement(Int_t i=0) const override
Retrieve the pointer to the element corresponding to component I.
TGeoNavigator * AddNavigator()
Add a new navigator to the array.
TGeoNavigator * GetCurrentNavigator() const
TGeoNavigator * SetCurrentNavigator(Int_t inav)
Class providing navigation API for TGeo geometries.
void CdUp()
Go one level up in geometry.
void DoBackupState()
Backup the current state without affecting the cache stack.
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
TGeoNode * CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode)
Cross next boundary and locate within current node The current point must be on the boundary of fCurr...
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
void LocalToMaster(const Double_t *local, Double_t *master) const
void CdNext()
Do a cd to the node found next by FindNextBoundary.
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
Bool_t cd(const char *path="")
Browse the tree of nodes starting from top node according to pathname.
Bool_t IsSameLocation(Double_t x, Double_t y, Double_t z, Bool_t change=kFALSE)
Checks if point (x,y,z) is still in the current node.
void MasterToLocal(const Double_t *master, Double_t *local) const
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
void InspectState() const
Inspects path and all flags for the current state.
TGeoNode * Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)
Make a rectiliniar step of length fStep from current point (fPoint) on current direction (fDirection)...
TGeoVolume * GetCurrentVolume() const
void ResetState()
Reset current state flags.
TGeoNode * FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE)
Computes as fStep the distance to next daughter of the current volume.
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
Bool_t CheckPath(const char *path) const
Check if a geometry path is valid without changing the state of the navigator.
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
void CdTop()
Make top level node the current node.
Int_t GetCurrentNodeId() const
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
void GetBranchOnlys(Int_t *isonly) const
Fill node copy numbers of current branch into an array.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=nullptr)
Returns the deepest node containing fPoint, which must be set a priori.
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const
Check if a new point with given coordinates is the same as the last located one.
void CdDown(Int_t index)
Make a daughter of current node current.
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
Double_t * FindNormal(Bool_t forward=kTRUE)
Computes normal vector to the next surface that will be or was already crossed when propagating on a ...
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
A node containing local transformation.
Definition TGeoNode.h:154
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
Bool_t IsOverlapping() const
Definition TGeoNode.h:107
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
void SaveAttributes(std::ostream &out)
save attributes for this node
Definition TGeoNode.cxx:440
void SetVolume(TGeoVolume *volume)
Definition TGeoNode.h:117
void CheckShapes()
check for wrong parameters in shapes
Definition TGeoNode.cxx:330
void SetOverlapping(Bool_t flag=kTRUE)
Definition TGeoNode.h:120
Int_t GetNdaughters() const
Definition TGeoNode.h:91
virtual TGeoMatrix * GetMatrix() const =0
void SetVisibility(Bool_t vis=kTRUE) override
Set visibility of the node (obsolete).
Definition TGeoNode.cxx:719
void SetMotherVolume(TGeoVolume *mother)
Definition TGeoNode.h:125
static TClass * Class()
TGeoVolume * GetMotherVolume() const
Definition TGeoNode.h:90
void SetNumber(Int_t number)
Definition TGeoNode.h:118
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition TGeoNode.cxx:193
This is a wrapper class to G4OpticalSurface.
The knowledge of the path to the objects that need to be misaligned is essential since there is no ot...
Base class for a flat parallel geometry.
Bool_t CloseGeometry()
The main geometry must be closed.
void RefreshPhysicalNodes()
Refresh the node pointers and re-voxelize.
Bool_t IsClosed() const
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
Regions are groups of volumes having a common set of user tracking cuts.
Definition TGeoRegion.h:36
Base abstract class for all shapes.
Definition TGeoShape.h:25
virtual Bool_t IsComposite() const
Definition TGeoShape.h:138
Bool_t IsRunTimeShape() const
Definition TGeoShape.h:150
virtual void ComputeBBox()=0
virtual void AfterStreamer()
Definition TGeoShape.h:100
@ kGeoClosedShape
Definition TGeoShape.h:59
TClass * IsA() const override
Definition TGeoShape.h:179
Bool_t TestShapeBit(UInt_t f) const
Definition TGeoShape.h:175
Volume assemblies.
Definition TGeoVolume.h:316
static TGeoVolumeAssembly * MakeAssemblyFromVolume(TGeoVolume *vol)
Make a clone of volume VOL but which is an assembly.
Volume families.
Definition TGeoVolume.h:266
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
Double_t WeightA() const
Analytical computation of the weight.
virtual void ClearThreadData() const
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
void SetNumber(Int_t number)
Definition TGeoVolume.h:245
void SetLineWidth(Width_t lwidth) override
Set the line width.
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:175
Int_t GetRefCount() const
Definition TGeoVolume.h:131
void SortNodes()
sort nodes by decreasing volume of the bounding box.
void Voxelize(Option_t *option)
build the voxels for this volume
Bool_t IsRunTime() const
Definition TGeoVolume.h:109
virtual void CreateThreadData(Int_t nthreads)
virtual Int_t GetByteCount() const
get the total size in bytes for this volume
Bool_t OptimizeVoxels()
Perform an extensive sampling to find which type of voxelization is most efficient.
virtual Bool_t IsVolumeMulti() const
Definition TGeoVolume.h:110
Int_t CountNodes(Int_t nlevels=1000, Int_t option=0)
Count total number of subnodes starting from this volume, nlevels down.
void UnmarkSaved()
Reset SavePrimitive bits.
void SetFinder(TGeoPatternFinder *finder)
Definition TGeoVolume.h:244
Int_t GetNdaughters() const
Definition TGeoVolume.h:362
void Grab()
Definition TGeoVolume.h:136
static TClass * Class()
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:376
void Release()
Definition TGeoVolume.h:137
void FindOverlaps() const
loop all nodes marked as overlaps and find overlapping brothers
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
virtual void SetMedium(TGeoMedium *medium)
Definition TGeoVolume.h:242
TGeoVoxelFinder * GetVoxels() const
Getter for optimization structure.
static TGeoMedium * DummyMedium()
void SetLineColor(Color_t lcolor) override
Set the line color.
Int_t GetNumber() const
Definition TGeoVolume.h:184
TGeoShape * GetShape() const
Definition TGeoVolume.h:190
void SaveAs(const char *filename="", Option_t *option="") const override
Save geometry having this as top volume as a C++ macro.
void SetField(TObject *field)
Definition TGeoVolume.h:231
static void CreateDummyMedium()
Create a dummy medium.
void SetLineStyle(Style_t lstyle) override
Set the line style.
virtual Bool_t IsAssembly() const
Returns true if the volume is an assembly or a scaled assembly.
TGeoVolume * MakeReflectedVolume(const char *newname="") const
Make a copy of this volume which is reflected with respect to XY plane.
virtual Bool_t IsVisible() const
Definition TGeoVolume.h:155
Finder class handling voxels.
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
Definition TGeoXtru.h:22
static TClass * Class()
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
void Clear(Option_t *option="") override
Remove all objects from the list.
TObject * FindObject(const char *name) const override
Find object using its name.
void AddLast(TObject *obj) override
Add object at the end of the list.
Definition THashList.cxx:95
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
virtual const char * GetClassName() const
Definition TKey.h:75
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition TKey.cxx:758
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:576
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:355
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:174
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TNamed()
Definition TNamed.h:38
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:150
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
Int_t IndexOf(const TObject *obj) const override
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
virtual void Sort(Int_t upto=kMaxInt)
If objects in array are sortable (i.e.
void Clear(Option_t *option="") override
Remove all objects from the array.
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
TObject * Remove(TObject *obj) override
Remove object from array.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Add(TObject *obj) override
Definition TObjArray.h:68
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:205
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:421
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition TObject.cxx:964
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1099
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:875
virtual TClass * IsA() const
Definition TObject.h:249
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
Sequenceable collection abstract base class.
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
const char * Data() const
Definition TString.h:376
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Abstract class for geometry checkers.
virtual void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="", Double_t safety=0.)=0
virtual void CheckGeometryFull(Bool_t checkoverlaps=kTRUE, Bool_t checkcrossings=kTRUE, Int_t nrays=10000, const Double_t *vertex=nullptr)=0
virtual void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)=0
virtual void RandomPoints(TGeoVolume *vol, Int_t npoints, Option_t *option)=0
virtual void Test(Int_t npoints, Option_t *option)=0
virtual void CheckBoundaryReference(Int_t icheck=-1)=0
virtual Double_t Weight(Double_t precision=0.01, Option_t *option="v")=0
virtual void SetNmeshPoints(Int_t npoints=1000)=0
virtual void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)=0
virtual TGeoNode * SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil, const char *g3path)=0
virtual void SetSelectedNode(TGeoNode *node)=0
virtual void TestOverlaps(const char *path)=0
virtual void RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol=nullptr, Bool_t check_norm=kFALSE)=0
Abstract class for geometry painters.
virtual void SetTopVisible(Bool_t vis=kTRUE)=0
virtual Int_t GetVisLevel() const =0
virtual void DrawPath(const char *path, Option_t *option="")=0
virtual void ModifiedPad(Bool_t update=kFALSE) const =0
virtual void GetViewAngles(Double_t &, Double_t &, Double_t &)
virtual TVirtualGeoTrack * AddTrack(Int_t id, Int_t pdgcode, TObject *particle)=0
virtual void SetExplodedView(Int_t iopt=0)=0
virtual Bool_t IsRaytracing() const =0
virtual void DrawCurrentPoint(Int_t color)=0
virtual void GrabFocus(Int_t nfr=0, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0)=0
virtual void SetVisOption(Int_t option=0)=0
virtual Double_t * GetViewBox()=0
virtual void EstimateCameraMove(Double_t, Double_t, Double_t *, Double_t *)
virtual void SetNsegments(Int_t nseg=20)=0
virtual Int_t CountVisibleNodes()=0
virtual void DefaultAngles()=0
virtual void UnbombTranslation(const Double_t *tr, Double_t *bombtr)=0
virtual void EditGeometry(Option_t *option="")=0
virtual void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const =0
virtual void BombTranslation(const Double_t *tr, Double_t *bombtr)=0
virtual void ExecuteManagerEvent(TGeoManager *geom, Int_t event, Int_t px, Int_t py)=0
virtual void SetBombFactors(Double_t bombx=1.3, Double_t bomby=1.3, Double_t bombz=1.3, Double_t bombr=1.3)=0
Base class for user-defined tracks attached to a geometry.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
std::ostream & Info()
Definition hadd.cxx:177
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TH1F * h1
Definition legend1.C:5
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...
Definition TROOT.cxx:501
Double_t ATan2(Double_t y, Double_t x)
Returns the principal value of the arc tangent of y/x, expressed in radians.
Definition TMath.h:652
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Definition TMathBase.h:347
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:73