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#include "TGeoColorScheme.h"
290
291// statics and globals
292
294
295std::mutex TGeoManager::fgMutex;
307
308////////////////////////////////////////////////////////////////////////////////
309/// Default constructor.
310
312{
313 if (!fgThreadId)
317 fTmin = 0.;
318 fTmax = 999.;
319 fPhiCut = kFALSE;
320 fPhimin = 0;
321 fPhimax = 360;
326 fClosed = kFALSE;
328 fBits = nullptr;
329 fCurrentNavigator = nullptr;
330 fMaterials = nullptr;
331 fHashPNE = nullptr;
332 fArrayPNE = nullptr;
333 fMatrices = nullptr;
334 fNodes = nullptr;
335 fOverlaps = nullptr;
336 fRegions = nullptr;
337 fNNodes = 0;
338 fMaxVisNodes = 10000;
339 fVolumes = nullptr;
340 fPhysicalNodes = nullptr;
341 fShapes = nullptr;
342 fGVolumes = nullptr;
343 fGShapes = nullptr;
344 fTracks = nullptr;
345 fMedia = nullptr;
346 fNtracks = 0;
347 fNpdg = 0;
348 fPdgNames = nullptr;
349 fGDMLMatrices = nullptr;
350 fOpticalSurfaces = nullptr;
351 fSkinSurfaces = nullptr;
352 fBorderSurfaces = nullptr;
353 memset(fPdgId, 0, 1024 * sizeof(Int_t));
354 // TObjArray *fNavigators; //! list of navigators
355 fCurrentTrack = nullptr;
356 fCurrentVolume = nullptr;
357 fTopVolume = nullptr;
358 fTopNode = nullptr;
359 fMasterVolume = nullptr;
360 fPainter = nullptr;
361 fChecker = nullptr;
364 fVisDensity = 0.;
365 fVisLevel = 3;
366 fVisOption = 1;
367 fExplodedView = 0;
368 fNsegments = 20;
369 fNLevel = 0;
370 fUniqueVolumes = nullptr;
371 fClippingShape = nullptr;
374 fGLMatrix = nullptr;
375 fPaintVolume = nullptr;
376 fUserPaintVolume = nullptr;
377 fElementTable = nullptr;
378 fHashVolumes = nullptr;
379 fHashGVolumes = nullptr;
380 fSizePNEId = 0;
381 fNPNEId = 0;
382 fKeyPNEId = nullptr;
383 fValuePNEId = nullptr;
385 fRaytraceMode = 0;
386 fMaxThreads = 0;
388 fParallelWorld = nullptr;
390 } else {
391 Init();
393 gGeoIdentity = new TGeoIdentity("Identity");
395 }
396}
397
398////////////////////////////////////////////////////////////////////////////////
399/// Constructor.
400
401TGeoManager::TGeoManager(const char *name, const char *title) : TNamed(name, title)
402{
403 if (!gROOT->GetListOfGeometries()->FindObject(this))
404 gROOT->GetListOfGeometries()->Add(this);
405 if (!gROOT->GetListOfBrowsables()->FindObject(this))
406 gROOT->GetListOfBrowsables()->Add(this);
407 Init();
408 gGeoIdentity = new TGeoIdentity("Identity");
410 if (fgVerboseLevel > 0)
411 Info("TGeoManager", "Geometry %s, %s created", GetName(), GetTitle());
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Initialize manager class.
416
418{
419 if (gGeoManager) {
420 Warning("Init", "Deleting previous geometry: %s/%s", gGeoManager->GetName(), gGeoManager->GetTitle());
421 delete gGeoManager;
422 if (fgLock)
423 Fatal("Init", "New geometry created while the old one locked !!!");
424 }
425
426 gGeoManager = this;
427 if (!fgThreadId)
430 fTmin = 0.;
431 fTmax = 999.;
432 fPhiCut = kFALSE;
433 fPhimin = 0;
434 fPhimax = 360;
439 fClosed = kFALSE;
441 fBits = new UChar_t[50000]; // max 25000 nodes per volume
442 fCurrentNavigator = nullptr;
443 fHashPNE = new THashList(256, 3);
444 fArrayPNE = nullptr;
445 fMaterials = new THashList(200, 3);
446 fMatrices = new TObjArray(256);
447 fNodes = new TObjArray(30);
448 fOverlaps = new TObjArray(256);
449 fRegions = new TObjArray(256);
450 fNNodes = 0;
451 fMaxVisNodes = 10000;
452 fVolumes = new TObjArray(256);
453 fPhysicalNodes = new TObjArray(256);
454 fShapes = new TObjArray(256);
455 fGVolumes = new TObjArray(256);
456 fGShapes = new TObjArray(256);
457 fTracks = new TObjArray(256);
458 fMedia = new THashList(200, 3);
459 fNtracks = 0;
460 fNpdg = 0;
461 fPdgNames = nullptr;
462 fGDMLMatrices = new TObjArray();
464 fSkinSurfaces = new TObjArray();
466 memset(fPdgId, 0, 1024 * sizeof(Int_t));
467 fCurrentTrack = nullptr;
468 fCurrentVolume = nullptr;
469 fTopVolume = nullptr;
470 fTopNode = nullptr;
471 fMasterVolume = nullptr;
472 fPainter = nullptr;
473 fChecker = nullptr;
476 fVisDensity = 0.;
477 fVisLevel = 3;
478 fVisOption = 1;
479 fExplodedView = 0;
480 fNsegments = 20;
481 fNLevel = 0;
482 fUniqueVolumes = new TObjArray(256);
483 fClippingShape = nullptr;
486 fGLMatrix = new TGeoHMatrix();
487 fPaintVolume = nullptr;
488 fUserPaintVolume = nullptr;
489 fElementTable = nullptr;
490 fHashVolumes = nullptr;
491 fHashGVolumes = nullptr;
492 fSizePNEId = 0;
493 fNPNEId = 0;
494 fKeyPNEId = nullptr;
495 fValuePNEId = nullptr;
497 fRaytraceMode = 0;
498 fMaxThreads = 0;
500 fParallelWorld = nullptr;
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// Destructor
506
508{
509 if (gGeoManager != this)
510 gGeoManager = this;
512
513 if (gROOT->GetListOfFiles()) { // in case this function is called from TROOT destructor
514 gROOT->GetListOfGeometries()->Remove(this);
515 gROOT->GetListOfBrowsables()->Remove(this);
516 }
517 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
518 // TIter next(brlist);
519 // TBrowser *browser = 0;
520 // while ((browser=(TBrowser*)next())) browser->RecursiveRemove(this);
523 delete TGeoBuilder::Instance(this);
524 if (fBits)
525 delete[] fBits;
528 if (fOverlaps) {
529 fOverlaps->Delete();
531 }
532 if (fRegions) {
533 fRegions->Delete();
535 }
536 if (fMaterials) {
539 }
541 if (fMedia) {
542 fMedia->Delete();
544 }
545 if (fHashVolumes) {
546 fHashVolumes->Clear("nodelete");
548 }
549 if (fHashGVolumes) {
550 fHashGVolumes->Clear("nodelete");
552 }
553 if (fHashPNE) {
554 fHashPNE->Delete();
556 }
557 if (fArrayPNE) {
558 delete fArrayPNE;
559 }
560 if (fVolumes) {
561 fVolumes->Delete();
563 }
564 if (fShapes) {
565 fShapes->Delete();
567 }
568 if (fPhysicalNodes) {
571 }
572 if (fMatrices) {
573 fMatrices->Delete();
575 }
576 if (fTracks) {
577 fTracks->Delete();
579 }
581 if (fPdgNames) {
582 fPdgNames->Delete();
584 }
585 if (fGDMLMatrices) {
588 }
589 if (fOpticalSurfaces) {
592 }
593 if (fSkinSurfaces) {
596 }
597 if (fBorderSurfaces) {
600 }
602 CleanGarbage();
606 if (fSizePNEId) {
607 delete[] fKeyPNEId;
608 delete[] fValuePNEId;
609 }
610 delete fParallelWorld;
612 gGeoIdentity = nullptr;
613 gGeoManager = nullptr;
614}
615
616////////////////////////////////////////////////////////////////////////////////
617/// Add a material to the list. Returns index of the material in list.
618
620{
621 return TGeoBuilder::Instance(this)->AddMaterial((TGeoMaterial *)material);
622}
623
624////////////////////////////////////////////////////////////////////////////////
625/// Add an illegal overlap/extrusion to the list.
626
633
634////////////////////////////////////////////////////////////////////////////////
635/// Add a new region of volumes.
642
643////////////////////////////////////////////////////////////////////////////////
644/// Add a user-defined property. Returns true if added, false if existing.
645
647{
648 auto pos = fProperties.insert(ConstPropMap_t::value_type(property, value));
649 if (!pos.second) {
650 Warning("AddProperty", "Property \"%s\" already exists with value %g", property, (pos.first)->second);
651 return false;
652 }
653 return true;
654}
655
656////////////////////////////////////////////////////////////////////////////////
657/// Get a user-defined property
658
660{
661 auto pos = fProperties.find(property);
662 if (pos == fProperties.end()) {
663 if (error)
664 *error = kTRUE;
665 return 0.;
666 }
667 if (error)
668 *error = kFALSE;
669 return pos->second;
670}
671
672////////////////////////////////////////////////////////////////////////////////
673/// Get a user-defined property from a given index
674
676{
677 // This is a quite inefficient way to access map elements, but needed for the GDML writer to
678 if (i >= fProperties.size()) {
679 if (error)
680 *error = kTRUE;
681 return 0.;
682 }
683 size_t pos = 0;
684 auto it = fProperties.begin();
685 while (pos < i) {
686 ++it;
687 ++pos;
688 }
689 if (error)
690 *error = kFALSE;
691 name = (*it).first;
692 return (*it).second;
693}
694
695////////////////////////////////////////////////////////////////////////////////
696/// Add a matrix to the list. Returns index of the matrix in list.
697
699{
700 return TGeoBuilder::Instance(this)->AddTransformation((TGeoMatrix *)matrix);
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Add a shape to the list. Returns index of the shape in list.
705
707{
708 return TGeoBuilder::Instance(this)->AddShape((TGeoShape *)shape);
709}
710
711////////////////////////////////////////////////////////////////////////////////
712/// Add a track to the list of tracks. Use this for primaries only. For secondaries,
713/// add them to the parent track. The method create objects that are registered
714/// to the analysis manager but have to be cleaned-up by the user via ClearTracks().
715
722
723////////////////////////////////////////////////////////////////////////////////
724/// Add a track to the list of tracks
725
732
733////////////////////////////////////////////////////////////////////////////////
734/// Makes a primary track but do not attach it to the list of tracks. The track
735/// can be attached as daughter to another one with TVirtualGeoTrack::AddTrack
736
742
743////////////////////////////////////////////////////////////////////////////////
744/// Add a volume to the list. Returns index of the volume in list.
745
747{
748 if (!volume) {
749 Error("AddVolume", "invalid volume");
750 return -1;
751 }
753 if (!uid)
754 uid++;
755 if (!fCurrentVolume) {
756 fCurrentVolume = volume;
757 fUniqueVolumes->AddAtAndExpand(volume, uid);
758 } else {
759 if (!strcmp(volume->GetName(), fCurrentVolume->GetName())) {
760 uid = fCurrentVolume->GetNumber();
761 } else {
762 fCurrentVolume = volume;
763 Int_t olduid = GetUID(volume->GetName());
764 if (olduid < 0) {
765 fUniqueVolumes->AddAtAndExpand(volume, uid);
766 } else {
767 uid = olduid;
768 }
769 }
770 }
771 volume->SetNumber(uid);
772 if (!fHashVolumes) {
773 fHashVolumes = new THashList(256);
774 fHashGVolumes = new THashList(256);
775 }
776 TObjArray *list = fVolumes;
777 if (!volume->GetShape() || volume->IsRunTime() || volume->IsVolumeMulti()) {
778 list = fGVolumes;
779 fHashGVolumes->Add(volume);
780 } else {
781 fHashVolumes->Add(volume);
782 }
783 Int_t index = list->GetEntriesFast();
784 list->AddAtAndExpand(volume, index);
785 return uid;
786}
787
788////////////////////////////////////////////////////////////////////////////////
789/// Add a navigator in the list of navigators. If it is the first one make it
790/// current navigator.
791
793{
794 if (fMultiThread) {
796 fgMutex.lock();
797 }
798 std::thread::id threadId = std::this_thread::get_id();
799 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
800 TGeoNavigatorArray *array = nullptr;
801 if (it != fNavigators.end())
802 array = it->second;
803 else {
804 array = new TGeoNavigatorArray(this);
805 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
806 }
807 TGeoNavigator *nav = array->AddNavigator();
808 if (fClosed)
809 nav->GetCache()->BuildInfoBranch();
810 if (fMultiThread)
811 fgMutex.unlock();
812 return nav;
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// Returns current navigator for the calling thread.
817
819{
820 TTHREAD_TLS(TGeoNavigator *) tnav = nullptr;
821 if (!fMultiThread)
822 return fCurrentNavigator;
823 TGeoNavigator *nav = tnav; // TTHREAD_TLS_GET(TGeoNavigator*,tnav);
824 if (nav)
825 return nav;
826 std::thread::id threadId = std::this_thread::get_id();
827 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
828 if (it == fNavigators.end())
829 return nullptr;
830 TGeoNavigatorArray *array = it->second;
831 nav = array->GetCurrentNavigator();
832 tnav = nav; // TTHREAD_TLS_SET(TGeoNavigator*,tnav,nav);
833 return nav;
834}
835
836////////////////////////////////////////////////////////////////////////////////
837/// Get list of navigators for the calling thread.
838
840{
841 std::thread::id threadId = std::this_thread::get_id();
842 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
843 if (it == fNavigators.end())
844 return nullptr;
845 TGeoNavigatorArray *array = it->second;
846 return array;
847}
848
849////////////////////////////////////////////////////////////////////////////////
850/// Switch to another existing navigator for the calling thread.
851
853{
854 std::thread::id threadId = std::this_thread::get_id();
855 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
856 if (it == fNavigators.end()) {
857 Error("SetCurrentNavigator", "No navigator defined for this thread\n");
858 std::cout << " thread id: " << threadId << std::endl;
859 return kFALSE;
860 }
861 TGeoNavigatorArray *array = it->second;
863 if (!nav) {
864 Error("SetCurrentNavigator", "Navigator %d not existing for this thread\n", index);
865 std::cout << " thread id: " << threadId << std::endl;
866 return kFALSE;
867 }
868 if (!fMultiThread)
870 return kTRUE;
871}
872
873////////////////////////////////////////////////////////////////////////////////
874/// Set the lock for navigators.
875
880
881////////////////////////////////////////////////////////////////////////////////
882/// Clear all navigators.
883
885{
886 if (fMultiThread)
887 fgMutex.lock();
888 TGeoNavigatorArray *arr = nullptr;
889 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
890 arr = (*it).second;
891 if (arr)
892 delete arr;
893 }
894 fNavigators.clear();
895 if (fMultiThread)
896 fgMutex.unlock();
897}
898
899////////////////////////////////////////////////////////////////////////////////
900/// Clear a single navigator.
901
903{
904 if (fMultiThread)
905 fgMutex.lock();
906 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
907 TGeoNavigatorArray *arr = (*it).second;
908 if (arr) {
909 if ((TGeoNavigator *)arr->Remove((TObject *)nav)) {
910 delete nav;
911 if (!arr->GetEntries())
912 fNavigators.erase(it);
913 if (fMultiThread)
914 fgMutex.unlock();
915 return;
916 }
917 }
918 }
919 Error("Remove navigator", "Navigator %p not found", nav);
920 if (fMultiThread)
921 fgMutex.unlock();
922}
923
924////////////////////////////////////////////////////////////////////////////////
925/// Set maximum number of threads for navigation.
926
928{
929 if (!fClosed) {
930 Error("SetMaxThreads", "Cannot set maximum number of threads before closing the geometry");
931 return;
932 }
933 if (!fMultiThread) {
935 std::thread::id threadId = std::this_thread::get_id();
936 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
937 if (it != fNavigators.end()) {
938 TGeoNavigatorArray *array = it->second;
939 fNavigators.erase(it);
940 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
941 }
942 }
943 if (fMaxThreads) {
946 }
947 fMaxThreads = nthreads + 1;
948 if (fMaxThreads > 0) {
951 }
952}
953
954////////////////////////////////////////////////////////////////////////////////
955
957{
958 if (!fMaxThreads)
959 return;
960 fgMutex.lock();
961 TIter next(fVolumes);
962 TGeoVolume *vol;
963 while ((vol = (TGeoVolume *)next()))
964 vol->ClearThreadData();
965 fgMutex.unlock();
966}
967
968////////////////////////////////////////////////////////////////////////////////
969/// Create thread private data for all geometry objects.
970
972{
973 if (!fMaxThreads)
974 return;
975 fgMutex.lock();
976 TIter next(fVolumes);
977 TGeoVolume *vol;
978 while ((vol = (TGeoVolume *)next()))
980 fgMutex.unlock();
981}
982
983////////////////////////////////////////////////////////////////////////////////
984/// Clear the current map of threads. This will be filled again by the calling
985/// threads via ThreadId calls.
986
988{
990 return;
991 fgMutex.lock();
992 if (!fgThreadId->empty())
993 fgThreadId->clear();
994 fgNumThreads = 0;
995 fgMutex.unlock();
996}
997
998////////////////////////////////////////////////////////////////////////////////
999/// Translates the current thread id to an ordinal number. This can be used to
1000/// manage data which is specific for a given thread.
1001
1003{
1004 TTHREAD_TLS(Int_t) tid = -1;
1005 Int_t ttid = tid; // TTHREAD_TLS_GET(Int_t,tid);
1006 if (ttid > -1)
1007 return ttid;
1009 return 0;
1010 std::thread::id threadId = std::this_thread::get_id();
1012 if (it != fgThreadId->end())
1013 return it->second;
1014 // Map needs to be updated.
1015 fgMutex.lock();
1016 (*fgThreadId)[threadId] = fgNumThreads;
1017 tid = fgNumThreads; // TTHREAD_TLS_SET(Int_t,tid,fgNumThreads);
1018 ttid = fgNumThreads++;
1019 fgMutex.unlock();
1020 return ttid;
1021}
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Describe how to browse this object.
1025
1027{
1028 if (!b)
1029 return;
1030 if (fMaterials)
1031 b->Add(fMaterials, "Materials");
1032 if (fMedia)
1033 b->Add(fMedia, "Media");
1034 if (fMatrices)
1035 b->Add(fMatrices, "Local transformations");
1036 if (fOverlaps)
1037 b->Add(fOverlaps, "Illegal overlaps");
1038 if (fTracks)
1039 b->Add(fTracks, "Tracks");
1040 if (fMasterVolume)
1041 b->Add(fMasterVolume, "Master Volume", fMasterVolume->IsVisible());
1042 if (fTopVolume)
1043 b->Add(fTopVolume, "Top Volume", fTopVolume->IsVisible());
1044 if (fTopNode)
1045 b->Add(fTopNode);
1046 TString browserImp(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
1047 TQObject::Connect(browserImp.Data(), "Checked(TObject*,Bool_t)", "TGeoManager", this,
1048 "SetVisibility(TObject*,Bool_t)");
1049}
1050
1051////////////////////////////////////////////////////////////////////////////////
1052/// Append a pad for this geometry.
1053
1059
1060////////////////////////////////////////////////////////////////////////////////
1061/// Set visibility for a volume.
1062
1064{
1065 if (obj->IsA() == TGeoVolume::Class()) {
1066 TGeoVolume *vol = (TGeoVolume *)obj;
1067 vol->SetVisibility(vis);
1068 } else {
1069 if (obj->InheritsFrom(TGeoNode::Class())) {
1070 TGeoNode *node = (TGeoNode *)obj;
1071 node->SetVisibility(vis);
1072 } else
1073 return;
1074 }
1076}
1077
1078////////////////////////////////////////////////////////////////////////////////
1079/// Get the new 'bombed' translation vector according current exploded view mode.
1080
1082{
1083 if (fPainter)
1085 return;
1086}
1087
1088////////////////////////////////////////////////////////////////////////////////
1089/// Get the new 'unbombed' translation vector according current exploded view mode.
1090
1092{
1093 if (fPainter)
1095 return;
1096}
1097
1098////////////////////////////////////////////////////////////////////////////////
1099/// Backup the current state without affecting the cache stack.
1100
1105
1106////////////////////////////////////////////////////////////////////////////////
1107/// Restore a backed-up state without affecting the cache stack.
1108
1113
1114////////////////////////////////////////////////////////////////////////////////
1115/// Register a matrix to the list of matrices. It will be cleaned-up at the
1116/// destruction TGeoManager.
1117
1119{
1120 return TGeoBuilder::Instance(this)->RegisterMatrix((TGeoMatrix *)matrix);
1121}
1122
1123////////////////////////////////////////////////////////////////////////////////
1124/// Replaces all occurrences of VORIG with VNEW in the geometry tree. The volume VORIG
1125/// is not replaced from the list of volumes, but all node referencing it will reference
1126/// VNEW instead. Returns number of occurrences changed.
1127
1129{
1130 Int_t nref = 0;
1131 if (!vorig || !vnew)
1132 return nref;
1133 TGeoMedium *morig = vorig->GetMedium();
1135 if (morig)
1136 checkmed = kTRUE;
1137 TGeoMedium *mnew = vnew->GetMedium();
1138 // Try to limit the damage produced by incorrect usage.
1139 if (!mnew && !vnew->IsAssembly()) {
1140 Error("ReplaceVolume", "Replacement volume %s has no medium and it is not an assembly", vnew->GetName());
1141 return nref;
1142 }
1143 if (mnew && checkmed) {
1144 if (mnew->GetId() != morig->GetId())
1145 Warning("ReplaceVolume", "Replacement volume %s has different medium than original volume %s", vnew->GetName(),
1146 vorig->GetName());
1147 checkmed = kFALSE;
1148 }
1149
1150 // Medium checking now performed only if replacement is an assembly and old volume a real one.
1151 // Check result is dependent on positioning.
1153 Int_t i, j, nd;
1154 Int_t ierr = 0;
1155 TGeoVolume *vol;
1156 TGeoNode *node;
1158 for (i = 0; i < nvol; i++) {
1159 vol = (TGeoVolume *)fVolumes->At(i);
1160 if (!vol)
1161 continue;
1162 if (vol == vorig || vol == vnew)
1163 continue;
1164 nd = vol->GetNdaughters();
1165 for (j = 0; j < nd; j++) {
1166 node = vol->GetNode(j);
1167 if (node->GetVolume() == vorig) {
1168 if (checkmed) {
1169 mnew = node->GetMotherVolume()->GetMedium();
1170 if (mnew && mnew->GetId() != morig->GetId())
1171 ierr++;
1172 }
1173 nref++;
1174 if (node->IsOverlapping()) {
1175 node->SetOverlapping(kFALSE);
1176 Info("ReplaceVolume", "%s replaced with assembly and declared NON-OVERLAPPING!", node->GetName());
1177 }
1178 node->SetVolume(vnew);
1179 voxels = node->GetMotherVolume()->GetVoxels();
1180 if (voxels)
1181 voxels->SetNeedRebuild();
1182 } else {
1183 if (node->GetMotherVolume() == vorig) {
1184 nref++;
1185 node->SetMotherVolume(vnew);
1186 if (node->IsOverlapping()) {
1187 node->SetOverlapping(kFALSE);
1188 Info("ReplaceVolume", "%s inside substitute assembly %s declared NON-OVERLAPPING!", node->GetName(),
1189 vnew->GetName());
1190 }
1191 }
1192 }
1193 }
1194 }
1195 if (ierr)
1196 Warning("ReplaceVolume",
1197 "Volumes should not be replaced with assemblies if they are positioned in containers having a different "
1198 "medium ID.\n %i occurrences for assembly replacing volume %s",
1199 ierr, vorig->GetName());
1200 return nref;
1201}
1202
1203////////////////////////////////////////////////////////////////////////////////
1204/// Rebuild the voxel structures that are flagged as needing rebuild.
1205
1207{
1209 TGeoVolume *vol;
1211 for (Int_t i = 0; i < nvol; i++) {
1212 vol = (TGeoVolume *)fVolumes->At(i);
1213 if (!vol)
1214 continue;
1215 voxels = vol->GetVoxels();
1216 if (voxels && voxels->NeedRebuild()) {
1217 voxels->Voxelize();
1218 vol->FindOverlaps(); // after voxelization, check overlaps again
1219 }
1220 }
1221}
1222
1223////////////////////////////////////////////////////////////////////////////////
1224/// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1225
1227{
1229 if (!toTransform) {
1230 Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1231 return 0;
1232 }
1234 Int_t count = 0;
1236 Bool_t replace = kTRUE;
1238 while (index < indmax) {
1239 if (replace) {
1240 replace = kFALSE;
1242 if (transformed) {
1244 count++;
1245 } else {
1246 if (toTransform->IsAssembly())
1247 Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1248 if (!toTransform->GetNdaughters())
1249 Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform",
1250 toTransform->GetName());
1251 if (toTransform->IsVolumeMulti())
1252 Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1253 }
1254 }
1255 index++;
1256 if (index >= indmax)
1257 return count;
1259 if (!strcmp(toTransform->GetName(), vname))
1260 replace = kTRUE;
1261 }
1262 return count;
1263}
1264
1265////////////////////////////////////////////////////////////////////////////////
1266/// Create a new volume by dividing an existing one (GEANT3 like)
1267///
1268/// Divides MOTHER into NDIV divisions called NAME
1269/// along axis IAXIS starting at coordinate value START
1270/// and having size STEP. The created volumes will have tracking
1271/// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1272/// The behavior of the division operation can be triggered using OPTION :
1273///
1274/// OPTION (case insensitive) :
1275/// - N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1276/// - NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1277/// - S - divide all range with given STEP. NDIV is computed and divisions will be centered
1278/// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1279/// - SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1280
1281TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start,
1283{
1284 return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1285}
1286
1287////////////////////////////////////////////////////////////////////////////////
1288/// Create rotation matrix named 'mat<index>'.
1289///
1290/// - index rotation matrix number
1291/// - theta1 polar angle for axis X
1292/// - phi1 azimuthal angle for axis X
1293/// - theta2 polar angle for axis Y
1294/// - phi2 azimuthal angle for axis Y
1295/// - theta3 polar angle for axis Z
1296/// - phi3 azimuthal angle for axis Z
1297///
1298
1304
1305////////////////////////////////////////////////////////////////////////////////
1306/// Create material with given A, Z and density, having an unique id.
1307
1310{
1311 return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1312}
1313
1314////////////////////////////////////////////////////////////////////////////////
1315/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1316/// materials defined by arrays A,Z and WMAT, having an unique id.
1317
1320{
1321 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1322}
1323
1324////////////////////////////////////////////////////////////////////////////////
1325/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1326/// materials defined by arrays A,Z and WMAT, having an unique id.
1327
1330{
1331 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1332}
1333
1334////////////////////////////////////////////////////////////////////////////////
1335/// Create tracking medium
1336///
1337/// - numed tracking medium number assigned
1338/// - name tracking medium name
1339/// - nmat material number
1340/// - isvol sensitive volume flag
1341/// - ifield magnetic field
1342/// - fieldm max. field value (kilogauss)
1343/// - tmaxfd max. angle due to field (deg/step)
1344/// - stemax max. step allowed
1345/// - deemax max. fraction of energy lost in a step
1346/// - epsil tracking precision (cm)
1347/// - stmin min. step due to continuous processes (cm)
1348///
1349/// - ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1350/// - ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1351/// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1352///
1353
1360
1361////////////////////////////////////////////////////////////////////////////////
1362/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1363/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1364/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1365/// In case npar>0, create the volume to be positioned in mother, according
1366/// its actual parameters (gsposp).
1367/// - NAME Volume name
1368/// - NUMBER Copy number of the volume
1369/// - MOTHER Mother volume name
1370/// - X X coord. of the volume in mother ref. sys.
1371/// - Y Y coord. of the volume in mother ref. sys.
1372/// - Z Z coord. of the volume in mother ref. sys.
1373/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1374/// - ISONLY ONLY/MANY flag
1375
1378{
1379 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1380}
1381
1382////////////////////////////////////////////////////////////////////////////////
1383/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1384/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1385/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1386/// In case npar>0, create the volume to be positioned in mother, according
1387/// its actual parameters (gsposp).
1388/// - NAME Volume name
1389/// - NUMBER Copy number of the volume
1390/// - MOTHER Mother volume name
1391/// - X X coord. of the volume in mother ref. sys.
1392/// - Y Y coord. of the volume in mother ref. sys.
1393/// - Z Z coord. of the volume in mother ref. sys.
1394/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1395/// - ISONLY ONLY/MANY flag
1396
1399{
1400 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1401}
1402
1403////////////////////////////////////////////////////////////////////////////////
1404/// Create a volume in GEANT3 style.
1405/// - NAME Volume name
1406/// - SHAPE Volume type
1407/// - NMED Tracking medium number
1408/// - NPAR Number of shape parameters
1409/// - UPAR Vector containing shape parameters
1410
1411TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar)
1412{
1413 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1414}
1415
1416////////////////////////////////////////////////////////////////////////////////
1417/// Create a volume in GEANT3 style.
1418/// - NAME Volume name
1419/// - SHAPE Volume type
1420/// - NMED Tracking medium number
1421/// - NPAR Number of shape parameters
1422/// - UPAR Vector containing shape parameters
1423
1425{
1426 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1427}
1428
1429////////////////////////////////////////////////////////////////////////////////
1430/// Assigns uid's for all materials,media and matrices.
1431
1433{
1434 Int_t index = 1;
1435 TIter next(fMaterials);
1437 while ((mater = (TGeoMaterial *)next())) {
1438 mater->SetUniqueID(index++);
1440 }
1441 index = 1;
1443 TGeoMedium *med;
1444 while ((med = (TGeoMedium *)next1())) {
1445 med->SetUniqueID(index++);
1447 }
1448 index = 1;
1450 TGeoShape *shape;
1451 while ((shape = (TGeoShape *)next2())) {
1452 shape->SetUniqueID(index++);
1453 if (shape->IsComposite())
1454 ((TGeoCompositeShape *)shape)->GetBoolNode()->RegisterMatrices();
1455 }
1456
1459 while ((matrix = (TGeoMatrix *)next3())) {
1460 matrix->RegisterYourself();
1461 }
1463 index = 1;
1464 while ((matrix = (TGeoMatrix *)next4())) {
1465 matrix->SetUniqueID(index++);
1467 }
1469 TGeoVolume *vol;
1470 while ((vol = (TGeoVolume *)next5()))
1471 vol->UnmarkSaved();
1472}
1473
1474////////////////////////////////////////////////////////////////////////////////
1475/// Reset all attributes to default ones. Default attributes for visualization
1476/// are those defined before closing the geometry.
1477
1479{
1480 if (gPad)
1481 delete gPad;
1482 gPad = nullptr;
1483 SetVisOption(0);
1484 SetVisLevel(3);
1485 SetExplodedView(0);
1487 if (!gStyle)
1488 return;
1489 TIter next(fVolumes);
1490 TGeoVolume *vol = nullptr;
1491 while ((vol = (TGeoVolume *)next())) {
1492 if (!vol->IsVisTouched())
1493 continue;
1494 vol->SetVisTouched(kFALSE);
1495 }
1496}
1497////////////////////////////////////////////////////////////////////////////////
1498/// Closing geometry implies checking the geometry validity, fixing shapes
1499/// with negative parameters (run-time shapes)building the cache manager,
1500/// voxelizing all volumes, counting the total number of physical nodes and
1501/// registering the manager class to the browser.
1502
1504{
1505 if (fClosed) {
1506 Warning("CloseGeometry", "geometry already closed");
1507 return;
1508 }
1509 if (!fMasterVolume) {
1510 Error("CloseGeometry", "you MUST call SetTopVolume() first !");
1511 return;
1512 }
1513 if (!gROOT->GetListOfGeometries()->FindObject(this))
1514 gROOT->GetListOfGeometries()->Add(this);
1515 if (!gROOT->GetListOfBrowsables()->FindObject(this))
1516 gROOT->GetListOfBrowsables()->Add(this);
1517 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1518 // TIter next(brlist);
1519 // TBrowser *browser = 0;
1520 // while ((browser=(TBrowser*)next())) browser->Refresh();
1521 TString opt(option);
1522 opt.ToLower();
1523 // Bool_t dummy = opt.Contains("d");
1524 Bool_t nodeid = opt.Contains("i");
1525 // Create a geometry navigator if not present
1526 TGeoNavigator *nav = nullptr;
1527 Int_t nnavigators = 0;
1528 // Check if the geometry is streamed from file
1529 if (fIsGeomReading) {
1530 if (fgVerboseLevel > 0)
1531 Info("CloseGeometry", "Geometry loaded from file...");
1533 if (!fElementTable)
1535 if (!fTopNode) {
1536 if (!fMasterVolume) {
1537 Error("CloseGeometry", "Master volume not streamed");
1538 return;
1539 }
1541 if (fStreamVoxels && fgVerboseLevel > 0)
1542 Info("CloseGeometry", "Voxelization retrieved from file");
1543 }
1544 // Create a geometry navigator if not present
1545 if (!GetCurrentNavigator())
1548 if (!opt.Contains("nv")) {
1549 Voxelize("ALL");
1550 }
1551 CountLevels();
1552 for (Int_t i = 0; i < nnavigators; i++) {
1554 nav->GetCache()->BuildInfoBranch();
1555 if (nodeid)
1556 nav->GetCache()->BuildIdArray();
1557 }
1558 if (!fHashVolumes) {
1561 fHashVolumes = new THashList(nvol + 1);
1562 fHashGVolumes = new THashList(ngvol + 1);
1563 Int_t i;
1564 for (i = 0; i < ngvol; i++)
1566 for (i = 0; i < nvol; i++)
1568 }
1569 fClosed = kTRUE;
1570 if (fParallelWorld) {
1571 if (fgVerboseLevel > 0)
1572 Info("CloseGeometry", "Recreating parallel world %s ...", fParallelWorld->GetName());
1574 }
1575
1576 if (fgVerboseLevel > 0)
1577 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1578 GetTitle());
1579 if (fgVerboseLevel > 0)
1580 Info("CloseGeometry", "----------------modeler ready----------------");
1581 return;
1582 }
1583
1584 // Create a geometry navigator if not present
1585 if (!GetCurrentNavigator())
1589 CheckGeometry();
1590 if (fgVerboseLevel > 0)
1591 Info("CloseGeometry", "Counting nodes...");
1592 fNNodes = CountNodes();
1593 fNLevel = fMasterVolume->CountNodes(1, 3) + 1;
1594 if (fNLevel < 30)
1595 fNLevel = 100;
1596
1597 // BuildIdArray();
1598 // avoid voxelization if requested to speed up geometry startup
1599 if (!opt.Contains("nv")) {
1600 Voxelize("ALL");
1601 } else {
1602 TGeoVolume *vol;
1603 TIter next(fVolumes);
1604 while ((vol = (TGeoVolume *)next())) {
1605 vol->SortNodes();
1606 }
1607 }
1608 if (fgVerboseLevel > 0)
1609 Info("CloseGeometry", "Building cache...");
1610 CountLevels();
1611 for (Int_t i = 0; i < nnavigators; i++) {
1613 nav->GetCache()->BuildInfoBranch();
1614 if (nodeid)
1615 nav->GetCache()->BuildIdArray();
1616 }
1617 fClosed = kTRUE;
1618 if (fgVerboseLevel > 0) {
1619 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1620 GetTitle());
1621 Info("CloseGeometry", "----------------modeler ready----------------");
1622 }
1623}
1624
1625////////////////////////////////////////////////////////////////////////////////
1626/// Clear the list of overlaps.
1627
1629{
1630 if (fOverlaps) {
1631 fOverlaps->Delete();
1632 delete fOverlaps;
1633 }
1634 fOverlaps = new TObjArray();
1635}
1636
1637////////////////////////////////////////////////////////////////////////////////
1638/// Remove a shape from the list of shapes.
1639
1641{
1642 if (fShapes->FindObject(shape))
1643 fShapes->Remove((TGeoShape *)shape);
1644 delete shape;
1645}
1646
1647////////////////////////////////////////////////////////////////////////////////
1648/// Clean temporary volumes and shapes from garbage collection.
1649
1651{
1652 if (!fGVolumes && !fGShapes)
1653 return;
1654 Int_t i, nentries;
1655 if (fGVolumes) {
1657 TGeoVolume *vol = nullptr;
1658 for (i = 0; i < nentries; i++) {
1659 vol = (TGeoVolume *)fGVolumes->At(i);
1660 if (vol)
1661 vol->SetFinder(nullptr);
1662 }
1663 fGVolumes->Delete();
1664 delete fGVolumes;
1665 fGVolumes = nullptr;
1666 }
1667 if (fGShapes) {
1668 fGShapes->Delete();
1669 delete fGShapes;
1670 fGShapes = nullptr;
1671 }
1672}
1673
1674////////////////////////////////////////////////////////////////////////////////
1675/// Change current path to point to the node having this id.
1676/// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1677
1679{
1680 GetCurrentNavigator()->CdNode(nodeid);
1681}
1682
1683////////////////////////////////////////////////////////////////////////////////
1684/// Get the unique ID of the current node.
1685
1690
1691////////////////////////////////////////////////////////////////////////////////
1692/// Make top level node the current node. Updates the cache accordingly.
1693/// Determine the overlapping state of current node.
1694
1696{
1698}
1699
1700////////////////////////////////////////////////////////////////////////////////
1701/// Go one level up in geometry. Updates cache accordingly.
1702/// Determine the overlapping state of current node.
1703
1705{
1707}
1708
1709////////////////////////////////////////////////////////////////////////////////
1710/// Make a daughter of current node current. Can be called only with a valid
1711/// daughter index (no check). Updates cache accordingly.
1712
1717
1718////////////////////////////////////////////////////////////////////////////////
1719/// Do a cd to the node found next by FindNextBoundary
1720
1722{
1724}
1725
1726////////////////////////////////////////////////////////////////////////////////
1727/// Browse the tree of nodes starting from fTopNode according to pathname.
1728/// Changes the path accordingly.
1729
1730Bool_t TGeoManager::cd(const char *path)
1731{
1732 return GetCurrentNavigator()->cd(path);
1733}
1734
1735////////////////////////////////////////////////////////////////////////////////
1736/// Check if a geometry path is valid without changing the state of the current navigator.
1737
1738Bool_t TGeoManager::CheckPath(const char *path) const
1739{
1740 return GetCurrentNavigator()->CheckPath(path);
1741}
1742
1743////////////////////////////////////////////////////////////////////////////////
1744/// Convert all reflections in geometry to normal rotations + reflected shapes.
1745
1747{
1748 if (!fTopNode)
1749 return;
1750 if (fgVerboseLevel > 0)
1751 Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1753 TGeoNode *node;
1757 while ((node = next())) {
1758 matrix = node->GetMatrix();
1759 if (matrix->IsReflection()) {
1760 // printf("%s before\n", node->GetName());
1761 // matrix->Print();
1763 mclone->RegisterYourself();
1764 // Reflect just the rotation component
1765 mclone->ReflectZ(kFALSE, kTRUE);
1766 nodematrix = (TGeoNodeMatrix *)node;
1767 nodematrix->SetMatrix(mclone);
1768 // printf("%s after\n", node->GetName());
1769 // node->GetMatrix()->Print();
1771 node->SetVolume(reflected);
1772 }
1773 }
1774 if (fgVerboseLevel > 0)
1775 Info("ConvertReflections", "Done");
1776}
1777
1778////////////////////////////////////////////////////////////////////////////////
1779/// Count maximum number of nodes per volume, maximum depth and maximum
1780/// number of xtru vertices.
1781
1783{
1784 if (!fTopNode) {
1785 Error("CountLevels", "Top node not defined.");
1786 return;
1787 }
1790 if (fMasterVolume->GetRefCount() > 1)
1792 if (fgVerboseLevel > 1 && fixrefs)
1793 Info("CountLevels", "Fixing volume reference counts");
1794 TGeoNode *node;
1795 Int_t maxlevel = 1;
1797 Int_t maxvertices = 1;
1798 while ((node = next())) {
1799 if (fixrefs) {
1800 node->GetVolume()->Grab();
1801 for (Int_t ibit = 10; ibit < 14; ibit++) {
1802 node->SetBit(BIT(ibit + 4), node->TestBit(BIT(ibit)));
1803 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1804 }
1805 }
1806 if (node->GetNdaughters() > maxnodes)
1807 maxnodes = node->GetNdaughters();
1808 if (next.GetLevel() > maxlevel)
1809 maxlevel = next.GetLevel();
1810 if (node->GetVolume()->GetShape()->IsA() == TGeoXtru::Class()) {
1811 TGeoXtru *xtru = (TGeoXtru *)node->GetVolume()->GetShape();
1812 if (xtru->GetNvert() > maxvertices)
1813 maxvertices = xtru->GetNvert();
1814 }
1815 }
1819 if (fgVerboseLevel > 0)
1820 Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1821}
1822
1823////////////////////////////////////////////////////////////////////////////////
1824/// Count the total number of nodes starting from a volume, nlevels down.
1825
1827{
1828 TGeoVolume *top;
1829 if (!vol) {
1830 top = fTopVolume;
1831 } else {
1832 top = (TGeoVolume *)vol;
1833 }
1834 Int_t count = top->CountNodes(nlevels, option);
1835 return count;
1836}
1837
1838////////////////////////////////////////////////////////////////////////////////
1839/// Set default angles for a given view.
1840
1842{
1843 if (fPainter)
1845}
1846
1847////////////////////////////////////////////////////////////////////////////////
1848/// Draw current point in the same view.
1849
1851{
1852 if (fPainter)
1853 fPainter->DrawCurrentPoint(color);
1854}
1855
1856////////////////////////////////////////////////////////////////////////////////
1857/// Draw animation of tracks
1858
1860{
1863 if (tmin < 0 || tmin >= tmax || nframes < 1)
1864 return;
1866 box[0] = box[1] = box[2] = 0;
1867 box[3] = box[4] = box[5] = 100;
1868 Double_t dt = (tmax - tmin) / Double_t(nframes);
1869 Double_t delt = 2E-9;
1870 Double_t t = tmin;
1871 Int_t i, j;
1872 TString opt(option);
1873 Bool_t save = kFALSE, geomanim = kFALSE;
1874 TString fname;
1875 if (opt.Contains("/S"))
1876 save = kTRUE;
1877
1878 if (opt.Contains("/G"))
1879 geomanim = kTRUE;
1880 SetTminTmax(0, 0);
1881 DrawTracks(opt.Data());
1882 Double_t start[6] = {0, 0, 0, 0, 0, 0};
1883 Double_t end[6] = {0, 0, 0, 0, 0, 0};
1884 Double_t dd[6] = {0, 0, 0, 0, 0, 0};
1885 Double_t dlat = 0, dlong = 0, dpsi = 0;
1886 if (geomanim) {
1887 fPainter->EstimateCameraMove(tmin + 5 * dt, tmin + 15 * dt, start, end);
1888 for (i = 0; i < 3; i++) {
1889 start[i + 3] = 20 + 1.3 * start[i + 3];
1890 end[i + 3] = 20 + 0.9 * end[i + 3];
1891 }
1892 for (i = 0; i < 6; i++) {
1893 dd[i] = (end[i] - start[i]) / 10.;
1894 }
1895 memcpy(box, start, 6 * sizeof(Double_t));
1897 dlong = (-206 - dlong) / Double_t(nframes);
1898 dlat = (126 - dlat) / Double_t(nframes);
1899 dpsi = (75 - dpsi) / Double_t(nframes);
1901 }
1902
1903 for (i = 0; i < nframes; i++) {
1904 if (t - delt < 0)
1905 SetTminTmax(t - delt, t);
1906 else
1907 gGeoManager->SetTminTmax(t - delt, t);
1908 if (geomanim) {
1909 for (j = 0; j < 6; j++)
1910 box[j] += dd[j];
1912 } else {
1913 ModifiedPad();
1914 }
1915 if (save) {
1916 fname = TString::Format("anim%04d.gif", i);
1917 gPad->Print(fname);
1918 }
1919 t += dt;
1920 }
1922}
1923
1924////////////////////////////////////////////////////////////////////////////////
1925/// Draw tracks over the geometry, according to option. By default, only
1926/// primaries are drawn. See TGeoTrack::Draw() for additional options.
1927
1929{
1931 // SetVisLevel(1);
1932 // SetVisOption(1);
1934 for (Int_t i = 0; i < fNtracks; i++) {
1935 track = GetTrack(i);
1936 if (track)
1937 track->Draw(option);
1938 }
1940 ModifiedPad();
1941}
1942
1943////////////////////////////////////////////////////////////////////////////////
1944/// Draw current path
1945
1946void TGeoManager::DrawPath(const char *path, Option_t *option)
1947{
1948 if (!fTopVolume)
1949 return;
1951 GetGeomPainter()->DrawPath(path, option);
1952}
1953
1954////////////////////////////////////////////////////////////////////////////////
1955/// Draw random points in the bounding box of a volume.
1956
1961
1962////////////////////////////////////////////////////////////////////////////////
1963/// Check time of finding "Where am I" for n points.
1964
1969
1970////////////////////////////////////////////////////////////////////////////////
1971/// Geometry overlap checker based on sampling.
1972
1973void TGeoManager::TestOverlaps(const char *path)
1974{
1976}
1977
1978////////////////////////////////////////////////////////////////////////////////
1979/// Fill volume names of current branch into an array.
1980
1982{
1984}
1985
1986////////////////////////////////////////////////////////////////////////////////
1987/// Get name for given pdg code;
1988
1990{
1991 static char defaultname[5] = {"XXX"};
1992 if (!fPdgNames || !pdg)
1993 return defaultname;
1994 for (Int_t i = 0; i < fNpdg; i++) {
1995 if (fPdgId[i] == pdg)
1996 return fPdgNames->At(i)->GetName();
1997 }
1998 return defaultname;
1999}
2000
2001////////////////////////////////////////////////////////////////////////////////
2002/// Set a name for a particle having a given pdg.
2003
2005{
2006 if (!pdg)
2007 return;
2008 if (!fPdgNames) {
2009 fPdgNames = new TObjArray(1024);
2010 }
2011 if (!strcmp(name, GetPdgName(pdg)))
2012 return;
2013 // store pdg name
2014 if (fNpdg > 1023) {
2015 Warning("SetPdgName", "No more than 256 different pdg codes allowed");
2016 return;
2017 }
2018 fPdgId[fNpdg] = pdg;
2019 TNamed *pdgname = new TNamed(name, "");
2021}
2022
2023////////////////////////////////////////////////////////////////////////////////
2024/// Get GDML matrix with a given name;
2025
2027{
2029}
2030
2031////////////////////////////////////////////////////////////////////////////////
2032/// Add GDML matrix;
2034{
2035 if (GetGDMLMatrix(mat->GetName())) {
2036 Error("AddGDMLMatrix", "Matrix %s already added to manager", mat->GetName());
2037 return;
2038 }
2040}
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Get optical surface with a given name;
2044
2049
2050////////////////////////////////////////////////////////////////////////////////
2051/// Add optical surface;
2053{
2054 if (GetOpticalSurface(optsurf->GetName())) {
2055 Error("AddOpticalSurface", "Surface %s already added to manager", optsurf->GetName());
2056 return;
2057 }
2059}
2060
2061////////////////////////////////////////////////////////////////////////////////
2062/// Get skin surface with a given name;
2063
2068
2069////////////////////////////////////////////////////////////////////////////////
2070/// Add skin surface;
2072{
2073 if (GetSkinSurface(surf->GetName())) {
2074 Error("AddSkinSurface", "Surface %s already added to manager", surf->GetName());
2075 return;
2076 }
2078}
2079
2080////////////////////////////////////////////////////////////////////////////////
2081/// Get border surface with a given name;
2082
2087
2088////////////////////////////////////////////////////////////////////////////////
2089/// Add border surface;
2091{
2092 if (GetBorderSurface(surf->GetName())) {
2093 Error("AddBorderSurface", "Surface %s already added to manager", surf->GetName());
2094 return;
2095 }
2097}
2098
2099////////////////////////////////////////////////////////////////////////////////
2100/// Fill node copy numbers of current branch into an array.
2101
2106
2107////////////////////////////////////////////////////////////////////////////////
2108/// Fill node copy numbers of current branch into an array.
2109
2114
2115////////////////////////////////////////////////////////////////////////////////
2116/// Retrieve cartesian and radial bomb factors.
2117
2119{
2120 if (fPainter) {
2122 return;
2123 }
2124 bombx = bomby = bombz = bombr = 1.3;
2125}
2126
2127////////////////////////////////////////////////////////////////////////////////
2128/// Return maximum number of daughters of a volume used in the geometry.
2129
2134
2135////////////////////////////////////////////////////////////////////////////////
2136/// Return maximum number of levels used in the geometry.
2137
2139{
2140 return fgMaxLevel;
2141}
2142
2143////////////////////////////////////////////////////////////////////////////////
2144/// Return maximum number of vertices for an xtru shape used.
2145
2150
2151////////////////////////////////////////////////////////////////////////////////
2152/// Returns number of threads that were set to use geometry.
2153
2158
2159////////////////////////////////////////////////////////////////////////////////
2160/// Return stored current matrix (global matrix of the next touched node).
2161
2163{
2164 if (!GetCurrentNavigator())
2165 return nullptr;
2166 return GetCurrentNavigator()->GetHMatrix();
2167}
2168
2169////////////////////////////////////////////////////////////////////////////////
2170/// Returns current depth to which geometry is drawn.
2171
2173{
2174 return fVisLevel;
2175}
2176
2177////////////////////////////////////////////////////////////////////////////////
2178/// Returns current depth to which geometry is drawn.
2179
2181{
2182 return fVisOption;
2183}
2184
2185////////////////////////////////////////////////////////////////////////////////
2186/// Find level of virtuality of current overlapping node (number of levels
2187/// up having the same tracking media.
2188
2193
2194////////////////////////////////////////////////////////////////////////////////
2195/// Search the track hierarchy to find the track with the
2196/// given id
2197///
2198/// if 'primsFirst' is true, then:
2199/// first tries TGeoManager::GetTrackOfId, then does a
2200/// recursive search if that fails. this would be faster
2201/// if the track is somehow known to be a primary
2202
2204{
2205 TVirtualGeoTrack *trk = nullptr;
2206 trk = GetTrackOfId(id);
2207 if (trk)
2208 return trk;
2209 // need recursive search
2210 TIter next(fTracks);
2212 while ((prim = (TVirtualGeoTrack *)next())) {
2213 trk = prim->FindTrackWithId(id);
2214 if (trk)
2215 return trk;
2216 }
2217 return nullptr;
2218}
2219
2220////////////////////////////////////////////////////////////////////////////////
2221/// Get track with a given ID.
2222
2224{
2226 for (Int_t i = 0; i < fNtracks; i++) {
2227 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2228 if (track->GetId() == id)
2229 return track;
2230 }
2231 }
2232 return nullptr;
2233}
2234
2235////////////////////////////////////////////////////////////////////////////////
2236/// Get parent track with a given ID.
2237
2239{
2241 while ((track = track->GetMother())) {
2242 if (track->GetId() == id)
2243 return track;
2244 }
2245 return nullptr;
2246}
2247
2248////////////////////////////////////////////////////////////////////////////////
2249/// Get index for track id, -1 if not found.
2250
2252{
2254 for (Int_t i = 0; i < fNtracks; i++) {
2255 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2256 if (track->GetId() == id)
2257 return i;
2258 }
2259 }
2260 return -1;
2261}
2262
2263////////////////////////////////////////////////////////////////////////////////
2264/// Go upwards the tree until a non-overlapping node
2265
2270
2271////////////////////////////////////////////////////////////////////////////////
2272/// Go upwards the tree until a non-overlapping node
2273
2278
2279////////////////////////////////////////////////////////////////////////////////
2280/// Set default volume colors according to A of material
2281///
2282/// If called with no argument, it uses the new default "natural" scheme
2283/// (including name-based material overrides) and falls back to Z-binned colors.
2284
2286{
2288 const TGeoColorScheme *scheme = cs ? cs : &defaultCS;
2289
2290 TGeoVolume *vol = nullptr;
2291 TIter next(fVolumes);
2292
2293 while ((vol = (TGeoVolume *)next())) {
2294 // Ask scheme for a color (>=0 means "use it")
2295 const Int_t c = scheme->Color(vol);
2296 if (c >= 0)
2297 vol->SetLineColor(c);
2298
2299 // Ask scheme for transparency ([0..100] means "use it")
2300 const Int_t t = scheme->Transparency(vol);
2301 if (t >= 0)
2302 vol->SetTransparency(t);
2303 }
2304 ModifiedPad();
2305}
2306
2307////////////////////////////////////////////////////////////////////////////////
2308/// Compute safe distance from the current point. This represent the distance
2309/// from POINT to the closest boundary.
2310
2312{
2313 return GetCurrentNavigator()->Safety(inside);
2314}
2315
2316////////////////////////////////////////////////////////////////////////////////
2317/// Set volume attributes in G3 style.
2318
2319void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2320{
2321 TGeoVolume *volume;
2322 Bool_t all = kFALSE;
2323 if (strstr(name, "*"))
2324 all = kTRUE;
2325 Int_t ivo = 0;
2326 TIter next(fVolumes);
2327 TString chatt = att;
2328 chatt.ToLower();
2329 while ((volume = (TGeoVolume *)next())) {
2330 if (strcmp(volume->GetName(), name) && !all)
2331 continue;
2332 ivo++;
2333 if (chatt.Contains("colo"))
2334 volume->SetLineColor(val);
2335 if (chatt.Contains("lsty"))
2336 volume->SetLineStyle(val);
2337 if (chatt.Contains("lwid"))
2338 volume->SetLineWidth(val);
2339 if (chatt.Contains("fill"))
2340 volume->SetFillColor(val);
2341 if (chatt.Contains("seen"))
2342 volume->SetVisibility(val);
2343 }
2345 while ((volume = (TGeoVolume *)next1())) {
2346 if (strcmp(volume->GetName(), name) && !all)
2347 continue;
2348 ivo++;
2349 if (chatt.Contains("colo"))
2350 volume->SetLineColor(val);
2351 if (chatt.Contains("lsty"))
2352 volume->SetLineStyle(val);
2353 if (chatt.Contains("lwid"))
2354 volume->SetLineWidth(val);
2355 if (chatt.Contains("fill"))
2356 volume->SetFillColor(val);
2357 if (chatt.Contains("seen"))
2358 volume->SetVisibility(val);
2359 }
2360 if (!ivo) {
2361 Warning("SetVolumeAttribute", "volume: %s does not exist", name);
2362 }
2363}
2364
2365////////////////////////////////////////////////////////////////////////////////
2366/// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2367
2373
2374////////////////////////////////////////////////////////////////////////////////
2375/// Set a user-defined shape as clipping for ray tracing.
2376
2378{
2380 if (shape) {
2381 if (fClippingShape && (fClippingShape != shape))
2383 fClippingShape = shape;
2384 }
2385 painter->SetClippingShape(shape);
2386}
2387
2388////////////////////////////////////////////////////////////////////////////////
2389/// set the maximum number of visible nodes.
2390
2392{
2394 if (maxnodes > 0 && fgVerboseLevel > 0)
2395 Info("SetMaxVisNodes", "Automatic visible depth for %d visible nodes", maxnodes);
2396 if (!fPainter)
2397 return;
2399 Int_t level = fPainter->GetVisLevel();
2400 if (level != fVisLevel)
2401 fVisLevel = level;
2402}
2403
2404////////////////////////////////////////////////////////////////////////////////
2405/// make top volume visible on screen
2406
2412
2413////////////////////////////////////////////////////////////////////////////////
2414/// Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
2415
2420
2421////////////////////////////////////////////////////////////////////////////////
2422/// Set the number of points to be generated on the shape outline when checking
2423/// for overlaps.
2424
2429
2430////////////////////////////////////////////////////////////////////////////////
2431/// set drawing mode :
2432/// - option=0 (default) all nodes drawn down to vislevel
2433/// - option=1 leaves and nodes at vislevel drawn
2434/// - option=2 path is drawn
2435/// - option=4 visibility changed
2436
2438{
2439 if ((option >= 0) && (option < 3))
2441 if (fPainter)
2443}
2444
2445////////////////////////////////////////////////////////////////////////////////
2446/// Set visualization option (leaves only OR all volumes)
2447
2449{
2450 if (flag)
2451 SetVisOption(1);
2452 else
2453 SetVisOption(0);
2454}
2455
2456////////////////////////////////////////////////////////////////////////////////
2457/// Set density threshold. Volumes with densities lower than this become
2458/// transparent.
2459
2466
2467////////////////////////////////////////////////////////////////////////////////
2468/// set default level down to which visualization is performed
2469
2471{
2472 if (level > 0) {
2473 fVisLevel = level;
2474 fMaxVisNodes = 0;
2475 if (fgVerboseLevel > 0)
2476 Info("SetVisLevel", "Automatic visible depth disabled");
2477 if (fPainter)
2479 } else {
2481 }
2482}
2483
2484////////////////////////////////////////////////////////////////////////////////
2485/// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2486
2488{
2489 fOverlaps->Sort();
2490}
2491
2492////////////////////////////////////////////////////////////////////////////////
2493/// Optimize voxelization type for all volumes. Save best choice in a macro.
2494
2496{
2497 if (!fTopNode) {
2498 Error("OptimizeVoxels", "Geometry must be closed first");
2499 return;
2500 }
2501 std::ofstream out;
2503 if (fname.IsNull())
2504 fname = "tgeovox.C";
2505 out.open(fname, std::ios::out);
2506 if (!out.good()) {
2507 Error("OptimizeVoxels", "cannot open file");
2508 return;
2509 }
2510 // write header
2511 TDatime t;
2513 sname.ReplaceAll(".C", "");
2514 out << sname.Data() << "()" << std::endl;
2515 out << "{" << std::endl;
2516 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2517 out << "//=== Voxel optimization for " << GetTitle() << " geometry" << std::endl;
2518 out << "//===== <run this macro JUST BEFORE closing the geometry>" << std::endl;
2519 out << " TGeoVolume *vol = 0;" << std::endl;
2520 out << " // parse all voxelized volumes" << std::endl;
2521 TGeoVolume *vol = nullptr;
2523 TIter next(fVolumes);
2524 while ((vol = (TGeoVolume *)next())) {
2525 if (!vol->GetVoxels())
2526 continue;
2527 out << " vol = gGeoManager->GetVolume(\"" << vol->GetName() << "\");" << std::endl;
2528 cyltype = vol->OptimizeVoxels();
2529 if (cyltype) {
2530 out << " vol->SetCylVoxels();" << std::endl;
2531 } else {
2532 out << " vol->SetCylVoxels(kFALSE);" << std::endl;
2533 }
2534 }
2535 out << "}" << std::endl;
2536 out.close();
2537}
2538////////////////////////////////////////////////////////////////////////////////
2539/// Parse a string boolean expression and do a syntax check. Find top
2540/// level boolean operator and returns its type. Fill the two
2541/// substrings to which this operator applies. The returned integer is :
2542/// - -1 : parse error
2543/// - 0 : no boolean operator
2544/// - 1 : union - represented as '+' in expression
2545/// - 2 : difference (subtraction) - represented as '-' in expression
2546/// - 3 : intersection - represented as '*' in expression.
2547/// Parentheses should be used to avoid ambiguities. For instance :
2548/// - A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2549/// eliminate not needed parentheses
2550
2552{
2554 Int_t len = startstr.Length();
2555 Int_t i;
2556 TString e0 = "";
2557 expr3 = "";
2558 // eliminate blanks
2559 for (i = 0; i < len; i++) {
2560 if (startstr(i) == ' ')
2561 continue;
2562 e0 += startstr(i, 1);
2563 }
2564 Int_t level = 0;
2565 Int_t levmin = 999;
2566 Int_t boolop = 0;
2567 Int_t indop = 0;
2568 Int_t iloop = 1;
2569 Int_t lastop = 0;
2570 Int_t lastdp = 0;
2571 Int_t lastpp = 0;
2573 // check/eliminate parentheses
2574 while (iloop == 1) {
2575 iloop = 0;
2576 lastop = 0;
2577 lastdp = 0;
2578 lastpp = 0;
2579 len = e0.Length();
2580 for (i = 0; i < len; i++) {
2581 if (e0(i) == '(') {
2582 if (!level)
2583 iloop++;
2584 level++;
2585 continue;
2586 }
2587 if (e0(i) == ')') {
2588 level--;
2589 if (level == 0)
2590 lastpp = i;
2591 continue;
2592 }
2593 if ((e0(i) == '+') || (e0(i) == '-') || (e0(i) == '*')) {
2594 lastop = i;
2595 if (level < levmin) {
2596 levmin = level;
2597 indop = i;
2598 }
2599 continue;
2600 }
2601 if ((e0(i) == ':') && (level == 0)) {
2602 lastdp = i;
2603 continue;
2604 }
2605 }
2606 if (level != 0) {
2607 if (gGeoManager)
2608 gGeoManager->Error("Parse", "parentheses does not match");
2609 return -1;
2610 }
2611 if (iloop == 1 && (e0(0) == '(') && (e0(len - 1) == ')')) {
2612 // eliminate extra parentheses
2613 e0 = e0(1, len - 2);
2614 continue;
2615 }
2616 if (foundmat)
2617 break;
2618 if (((lastop == 0) && (lastdp > 0)) || ((lastpp > 0) && (lastdp > lastpp) && (indop < lastpp))) {
2619 expr3 = e0(lastdp + 1, len - lastdp);
2620 e0 = e0(0, lastdp);
2621 foundmat = kTRUE;
2622 iloop = 1;
2623 continue;
2624 } else
2625 break;
2626 }
2627 // loop expression and search parentheses/operators
2628 levmin = 999;
2629 for (i = 0; i < len; i++) {
2630 if (e0(i) == '(') {
2631 level++;
2632 continue;
2633 }
2634 if (e0(i) == ')') {
2635 level--;
2636 continue;
2637 }
2638 // Take LAST operator at lowest level (revision 28/07/08)
2639 if (level <= levmin) {
2640 if (e0(i) == '+') {
2641 boolop = 1; // union
2642 levmin = level;
2643 indop = i;
2644 }
2645 if (e0(i) == '-') {
2646 boolop = 2; // difference
2647 levmin = level;
2648 indop = i;
2649 }
2650 if (e0(i) == '*') {
2651 boolop = 3; // intersection
2652 levmin = level;
2653 indop = i;
2654 }
2655 }
2656 }
2657 if (indop == 0) {
2658 expr1 = e0;
2659 return indop;
2660 }
2661 expr1 = e0(0, indop);
2662 expr2 = e0(indop + 1, len - indop);
2663 return boolop;
2664}
2665
2666////////////////////////////////////////////////////////////////////////////////
2667/// Save current attributes in a macro
2668
2670{
2671 if (!fTopNode) {
2672 Error("SaveAttributes", "geometry must be closed first\n");
2673 return;
2674 }
2675 std::ofstream out;
2677 if (fname.IsNull())
2678 fname = "tgeoatt.C";
2679 out.open(fname, std::ios::out);
2680 if (!out.good()) {
2681 Error("SaveAttributes", "cannot open file");
2682 return;
2683 }
2684 // write header
2685 TDatime t;
2687 sname.ReplaceAll(".C", "");
2688 out << sname.Data() << "()" << std::endl;
2689 out << "{" << std::endl;
2690 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2691 out << "//=== Attributes for " << GetTitle() << " geometry" << std::endl;
2692 out << "//===== <run this macro AFTER loading the geometry in memory>" << std::endl;
2693 // save current top volume
2694 out << " TGeoVolume *top = gGeoManager->GetVolume(\"" << fTopVolume->GetName() << "\");" << std::endl;
2695 out << " TGeoVolume *vol = 0;" << std::endl;
2696 out << " TGeoNode *node = 0;" << std::endl;
2697 out << " // clear all volume attributes and get painter" << std::endl;
2698 out << " gGeoManager->ClearAttributes();" << std::endl;
2699 out << " gGeoManager->GetGeomPainter();" << std::endl;
2700 out << " // set visualization modes and bomb factors" << std::endl;
2701 out << " gGeoManager->SetVisOption(" << GetVisOption() << ");" << std::endl;
2702 out << " gGeoManager->SetVisLevel(" << GetVisLevel() << ");" << std::endl;
2703 out << " gGeoManager->SetExplodedView(" << GetBombMode() << ");" << std::endl;
2706 out << " gGeoManager->SetBombFactors(" << bombx << "," << bomby << "," << bombz << "," << bombr << ");"
2707 << std::endl;
2708 out << " // iterate volumes container and set new attributes" << std::endl;
2709 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2710 TGeoVolume *vol = nullptr;
2712
2713 TIter next(fVolumes);
2714 while ((vol = (TGeoVolume *)next())) {
2715 vol->SetVisStreamed(kFALSE);
2716 }
2717 out << " // draw top volume with new settings" << std::endl;
2718 out << " top->Draw();" << std::endl;
2719 out << " gPad->x3d();" << std::endl;
2720 out << "}" << std::endl;
2721 out.close();
2722}
2723
2724////////////////////////////////////////////////////////////////////////////////
2725/// Returns the deepest node containing fPoint, which must be set a priori.
2726
2731
2732////////////////////////////////////////////////////////////////////////////////
2733/// Cross next boundary and locate within current node
2734/// The current point must be on the boundary of fCurrentNode.
2735
2740
2741////////////////////////////////////////////////////////////////////////////////
2742/// Compute distance to next boundary within STEPMAX. If no boundary is found,
2743/// propagate current point along current direction with fStep=STEPMAX. Otherwise
2744/// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2745/// node.
2746
2751
2752////////////////////////////////////////////////////////////////////////////////
2753/// Find distance to next boundary and store it in fStep. Returns node to which this
2754/// boundary belongs. If PATH is specified, compute only distance to the node to which
2755/// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2756/// than this value. STEPMAX represent the step to be made imposed by other reasons than
2757/// geometry (usually physics processes). Therefore in this case this method provides the
2758/// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2759/// fStep with a big number.
2760/// In case frombdr=kTRUE, the isotropic safety is set to zero.
2761///
2762/// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2763/// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2764/// they want this computed for the current point.
2765
2767{
2768 // convert current point and direction to local reference
2770}
2771
2772////////////////////////////////////////////////////////////////////////////////
2773/// Computes as fStep the distance to next daughter of the current volume.
2774/// The point and direction must be converted in the coordinate system of the current volume.
2775/// The proposed step limit is fStep.
2776
2781
2782////////////////////////////////////////////////////////////////////////////////
2783/// Reset current state flags.
2784
2789
2790////////////////////////////////////////////////////////////////////////////////
2791/// Returns deepest node containing current point.
2792
2797
2798////////////////////////////////////////////////////////////////////////////////
2799/// Returns deepest node containing current point.
2800
2805
2806////////////////////////////////////////////////////////////////////////////////
2807/// Computes fast normal to next crossed boundary, assuming that the current point
2808/// is close enough to the boundary. Works only after calling FindNextBoundary.
2809
2814
2815////////////////////////////////////////////////////////////////////////////////
2816/// Computes normal vector to the next surface that will be or was already
2817/// crossed when propagating on a straight line from a given point/direction.
2818/// Returns the normal vector cosines in the MASTER coordinate system. The dot
2819/// product of the normal and the current direction is positive defined.
2820
2822{
2823 return GetCurrentNavigator()->FindNormal(forward);
2824}
2825
2826////////////////////////////////////////////////////////////////////////////////
2827/// Checks if point (x,y,z) is still in the current node.
2828
2833
2834////////////////////////////////////////////////////////////////////////////////
2835/// Check if a new point with given coordinates is the same as the last located one.
2836
2841
2842////////////////////////////////////////////////////////////////////////////////
2843/// True if current node is in phi range
2844
2846{
2847 if (!fPhiCut)
2848 return kTRUE;
2849 const Double_t *origin;
2851 return kFALSE;
2852 origin = ((TGeoBBox *)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2853 Double_t point[3];
2854 LocalToMaster(origin, &point[0]);
2855 Double_t phi = TMath::ATan2(point[1], point[0]) * TMath::RadToDeg();
2856 if (phi < 0)
2857 phi += 360.;
2858 if ((phi >= fPhimin) && (phi <= fPhimax))
2859 return kFALSE;
2860 return kTRUE;
2861}
2862
2863////////////////////////////////////////////////////////////////////////////////
2864/// Initialize current point and current direction vector (normalized)
2865/// in MARS. Return corresponding node.
2866
2868{
2869 return GetCurrentNavigator()->InitTrack(point, dir);
2870}
2871
2872////////////////////////////////////////////////////////////////////////////////
2873/// Initialize current point and current direction vector (normalized)
2874/// in MARS. Return corresponding node.
2875
2880
2881////////////////////////////////////////////////////////////////////////////////
2882/// Inspects path and all flags for the current state.
2883
2888
2889////////////////////////////////////////////////////////////////////////////////
2890/// Get path to the current node in the form /node0/node1/...
2891
2892const char *TGeoManager::GetPath() const
2893{
2894 return GetCurrentNavigator()->GetPath();
2895}
2896
2897////////////////////////////////////////////////////////////////////////////////
2898/// Get total size of geometry in bytes.
2899
2901{
2902 Int_t count = 0;
2903 TIter next(fVolumes);
2904 TGeoVolume *vol;
2905 while ((vol = (TGeoVolume *)next()))
2906 count += vol->GetByteCount();
2909 while ((matrix = (TGeoMatrix *)next1()))
2910 count += matrix->GetByteCount();
2913 while ((mat = (TGeoMaterial *)next2()))
2914 count += mat->GetByteCount();
2916 TGeoMedium *med;
2917 while ((med = (TGeoMedium *)next3()))
2918 count += med->GetByteCount();
2919 if (fgVerboseLevel > 0)
2920 Info("GetByteCount", "Total size of logical tree : %i bytes", count);
2921 return count;
2922}
2923
2924////////////////////////////////////////////////////////////////////////////////
2925/// Make a default painter if none present. Returns pointer to it.
2926
2928{
2929 if (!fPainter) {
2930 const char *kind = nullptr;
2931 if (gPad)
2932 kind = gPad->IsWeb() ? "web" : "root";
2933 else
2934 kind = gEnv->GetValue("GeomPainter.Name", "");
2935
2936 if (!kind || !*kind)
2937 kind = (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch()) ? "web" : "root";
2938
2939 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter", kind)) {
2940 if (h->LoadPlugin() == -1) {
2941 Error("GetGeomPainter", "could not load plugin for %s geo_painter", kind);
2942 return nullptr;
2943 }
2944 fPainter = (TVirtualGeoPainter *)h->ExecPlugin(1, this);
2945 if (!fPainter) {
2946 Error("GetGeomPainter", "could not create %s geo_painter", kind);
2947 return nullptr;
2948 }
2949 } else {
2950 Error("GetGeomPainter", "not found plugin %s for geo_painter", kind);
2951 }
2952 }
2953 return fPainter;
2954}
2955
2956////////////////////////////////////////////////////////////////////////////////
2957/// Make a default checker if none present. Returns pointer to it.
2958
2960{
2961 if (!fChecker) {
2962 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoChecker", "root")) {
2963 if (h->LoadPlugin() == -1) {
2964 Error("GetGeomChecker", "could not load plugin for geo_checker");
2965 return nullptr;
2966 }
2967 fChecker = (TVirtualGeoChecker *)h->ExecPlugin(1, this);
2968 if (!fChecker) {
2969 Error("GetGeomChecker", "could not create geo_checker");
2970 return nullptr;
2971 }
2972 } else {
2973 Error("GetGeomChecker", "not found plugin for geo_checker");
2974 }
2975 }
2976 return fChecker;
2977}
2978
2979////////////////////////////////////////////////////////////////////////////////
2980/// Search for a named volume. All trailing blanks stripped.
2981
2983{
2984 TString sname = name;
2985 sname = sname.Strip();
2986 TGeoVolume *vol = (TGeoVolume *)fVolumes->FindObject(sname.Data());
2987 return vol;
2988}
2989
2990////////////////////////////////////////////////////////////////////////////////
2991/// Fast search for a named volume. All trailing blanks stripped.
2992
2994{
2995 if (!fHashVolumes) {
2998 fHashVolumes = new THashList(nvol + 1);
2999 fHashGVolumes = new THashList(ngvol + 1);
3000 Int_t i;
3001 for (i = 0; i < ngvol; i++)
3003 for (i = 0; i < nvol; i++)
3005 }
3006 TString sname = name;
3007 sname = sname.Strip();
3008 THashList *list = fHashVolumes;
3009 if (multi)
3010 list = fHashGVolumes;
3011 TGeoVolume *vol = (TGeoVolume *)list->FindObject(sname.Data());
3012 return vol;
3013}
3014
3015////////////////////////////////////////////////////////////////////////////////
3016/// Retrieve unique id for a volume name. Return -1 if name not found.
3017
3019{
3020 TGeoManager *geom = (TGeoManager *)this;
3021 TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
3022 if (!vol)
3023 vol = geom->FindVolumeFast(volname, kTRUE);
3024 if (!vol)
3025 return -1;
3026 return vol->GetNumber();
3027}
3028
3029////////////////////////////////////////////////////////////////////////////////
3030/// Find if a given material duplicates an existing one.
3031
3033{
3035 if (index <= 0)
3036 return nullptr;
3038 for (Int_t i = 0; i < index; i++) {
3040 if (other == mat)
3041 continue;
3042 if (other->IsEq(mat))
3043 return other;
3044 }
3045 return nullptr;
3046}
3047
3048////////////////////////////////////////////////////////////////////////////////
3049/// Search for a named material. All trailing blanks stripped.
3050
3052{
3054 sname = sname.Strip();
3056 return mat;
3057}
3058
3059////////////////////////////////////////////////////////////////////////////////
3060/// Search for a named tracking medium. All trailing blanks stripped.
3061
3063{
3065 sname = sname.Strip();
3067 return med;
3068}
3069
3070////////////////////////////////////////////////////////////////////////////////
3071/// Search for a tracking medium with a given ID.
3072
3074{
3075 TIter next(fMedia);
3076 TGeoMedium *med;
3077 while ((med = (TGeoMedium *)next())) {
3078 if (med->GetId() == numed)
3079 return med;
3080 }
3081 return nullptr;
3082}
3083
3084////////////////////////////////////////////////////////////////////////////////
3085/// Return material at position id.
3086
3088{
3090 return nullptr;
3092 return mat;
3093}
3094
3095////////////////////////////////////////////////////////////////////////////////
3096/// Return index of named material.
3097
3099{
3100 TIter next(fMaterials);
3102 Int_t id = 0;
3104 sname = sname.Strip();
3105 while ((mat = (TGeoMaterial *)next())) {
3106 if (!strcmp(mat->GetName(), sname.Data()))
3107 return id;
3108 id++;
3109 }
3110 return -1; // fail
3111}
3112
3113////////////////////////////////////////////////////////////////////////////////
3114/// Randomly shoot nrays and plot intersections with surfaces for current
3115/// top node.
3116
3122
3123////////////////////////////////////////////////////////////////////////////////
3124/// Remove material at given index.
3125
3127{
3128 TObject *obj = fMaterials->At(index);
3129 if (obj)
3130 fMaterials->Remove(obj);
3131}
3132
3133////////////////////////////////////////////////////////////////////////////////
3134/// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
3135/// from geometry. Deletion has to be managed by users.
3136
3138{
3139 TIter next(fVolumes);
3140 TGeoVolume *vol;
3141 while ((vol = (TGeoVolume *)next()))
3142 vol->SetField(nullptr);
3143}
3144
3145////////////////////////////////////////////////////////////////////////////////
3146/// Change raytracing mode.
3147
3154
3155////////////////////////////////////////////////////////////////////////////////
3156/// Restore the master volume of the geometry.
3157
3159{
3161 return;
3162 if (fMasterVolume)
3164}
3165
3166////////////////////////////////////////////////////////////////////////////////
3167/// Voxelize all non-divided volumes.
3168
3170{
3171 TGeoVolume *vol;
3172 // TGeoVoxelFinder *vox = 0;
3173 if (!fStreamVoxels && fgVerboseLevel > 0)
3174 Info("Voxelize", "Voxelizing...");
3175 // Int_t nentries = fVolumes->GetSize();
3176 TIter next(fVolumes);
3177 while ((vol = (TGeoVolume *)next())) {
3178 if (!fIsGeomReading)
3179 vol->SortNodes();
3180 if (!fStreamVoxels) {
3181 vol->Voxelize(option);
3182 }
3183 if (!fIsGeomReading)
3184 vol->FindOverlaps();
3185 }
3186}
3187
3188////////////////////////////////////////////////////////////////////////////////
3189/// Send "Modified" signal to painter.
3190
3192{
3193 if (!fPainter)
3194 return;
3196}
3197
3198////////////////////////////////////////////////////////////////////////////////
3199/// Make an TGeoArb8 volume.
3200
3202{
3203 return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
3204}
3205
3206////////////////////////////////////////////////////////////////////////////////
3207/// Make in one step a volume pointing to a box shape with given medium.
3208
3213
3214////////////////////////////////////////////////////////////////////////////////
3215/// Make in one step a volume pointing to a parallelepiped shape with given medium.
3216
3218 Double_t alpha, Double_t theta, Double_t phi)
3219{
3220 return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
3221}
3222
3223////////////////////////////////////////////////////////////////////////////////
3224/// Make in one step a volume pointing to a sphere shape with given medium
3225
3231
3232////////////////////////////////////////////////////////////////////////////////
3233/// Make in one step a volume pointing to a torus shape with given medium.
3234
3240
3241////////////////////////////////////////////////////////////////////////////////
3242/// Make in one step a volume pointing to a tube shape with given medium.
3243
3248
3249////////////////////////////////////////////////////////////////////////////////
3250/// Make in one step a volume pointing to a tube segment shape with given medium.
3251/// The segment will be from phiStart to phiEnd, the angles are expressed in degree
3252
3258
3259////////////////////////////////////////////////////////////////////////////////
3260/// Make in one step a volume pointing to a tube shape with given medium
3261
3263{
3264 return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
3265}
3266
3267////////////////////////////////////////////////////////////////////////////////
3268/// Make in one step a volume pointing to a tube shape with given medium
3269
3275
3276////////////////////////////////////////////////////////////////////////////////
3277/// Make in one step a volume pointing to a tube shape with given medium
3278
3283
3284////////////////////////////////////////////////////////////////////////////////
3285/// Make in one step a volume pointing to a tube segment shape with given medium
3286
3293
3294////////////////////////////////////////////////////////////////////////////////
3295/// Make in one step a volume pointing to a cone shape with given medium.
3296
3302
3303////////////////////////////////////////////////////////////////////////////////
3304/// Make in one step a volume pointing to a cone segment shape with given medium
3305
3311
3312////////////////////////////////////////////////////////////////////////////////
3313/// Make in one step a volume pointing to a polycone shape with given medium.
3314
3316{
3317 return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3318}
3319
3320////////////////////////////////////////////////////////////////////////////////
3321/// Make in one step a volume pointing to a polygone shape with given medium.
3322
3323TGeoVolume *
3325{
3326 return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3327}
3328
3329////////////////////////////////////////////////////////////////////////////////
3330/// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3331
3332TGeoVolume *
3337
3338////////////////////////////////////////////////////////////////////////////////
3339/// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3340
3346
3347////////////////////////////////////////////////////////////////////////////////
3348/// Make in one step a volume pointing to a trapezoid shape with given medium.
3349
3353{
3354 return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2,
3355 alpha2);
3356}
3357
3358////////////////////////////////////////////////////////////////////////////////
3359/// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3360
3368
3369////////////////////////////////////////////////////////////////////////////////
3370/// Make a TGeoXtru-shaped volume with nz planes
3371
3373{
3374 return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3375}
3376
3377////////////////////////////////////////////////////////////////////////////////
3378/// Creates an alignable object with unique name corresponding to a path
3379/// and adds it to the list of alignables. An optional unique ID can be
3380/// provided, in which case PN entries can be searched fast by uid.
3381
3383{
3384 if (!CheckPath(path))
3385 return nullptr;
3386 if (!fHashPNE)
3387 fHashPNE = new THashList(256, 3);
3388 if (!fArrayPNE)
3389 fArrayPNE = new TObjArray(256);
3391 if (entry) {
3392 Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3393 return nullptr;
3394 }
3395 entry = new TGeoPNEntry(unique_name, path);
3397 fHashPNE->Add(entry);
3399 if (uid >= 0) {
3401 if (!added)
3402 Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3403 }
3404 return entry;
3405}
3406
3407////////////////////////////////////////////////////////////////////////////////
3408/// Retrieves an existing alignable object.
3409
3411{
3412 if (!fHashPNE)
3413 return nullptr;
3414 return (TGeoPNEntry *)fHashPNE->FindObject(name);
3415}
3416
3417////////////////////////////////////////////////////////////////////////////////
3418/// Retrieves an existing alignable object at a given index.
3419
3421{
3422 if (!fArrayPNE && !InitArrayPNE())
3423 return nullptr;
3424 return (TGeoPNEntry *)fArrayPNE->At(index);
3425}
3426
3427////////////////////////////////////////////////////////////////////////////////
3428/// Retrieves an existing alignable object having a preset UID.
3429
3431{
3432 if (!fNPNEId || (!fArrayPNE && !InitArrayPNE()))
3433 return nullptr;
3435 if (index < 0 || fKeyPNEId[index] != uid)
3436 return nullptr;
3438}
3439
3440////////////////////////////////////////////////////////////////////////////////
3441/// Retrieves number of PN entries with or without UID.
3442
3444{
3445 if (!fHashPNE)
3446 return 0;
3447 if (with_uid)
3448 return fNPNEId;
3449 return fHashPNE->GetSize();
3450}
3451
3452////////////////////////////////////////////////////////////////////////////////
3453/// Insert a PN entry in the sorted array of indexes.
3454
3456{
3457 if (!fSizePNEId) {
3458 // Create the arrays.
3459 fSizePNEId = 128;
3460 fKeyPNEId = new Int_t[fSizePNEId];
3461 memset(fKeyPNEId, 0, fSizePNEId * sizeof(Int_t));
3463 memset(fValuePNEId, 0, fSizePNEId * sizeof(Int_t));
3464 fKeyPNEId[fNPNEId] = uid;
3466 return kTRUE;
3467 }
3468 // Search id in the existing array and return false if it already exists.
3470 if (index > 0 && fKeyPNEId[index] == uid)
3471 return kFALSE;
3472 // Resize the arrays and insert the value
3473 Bool_t resize = (fNPNEId == fSizePNEId) ? kTRUE : kFALSE;
3474 if (resize) {
3475 // Double the size of the array
3476 fSizePNEId *= 2;
3477 // Create new arrays of keys and values
3478 Int_t *keys = new Int_t[fSizePNEId];
3479 memset(keys, 0, fSizePNEId * sizeof(Int_t));
3480 Int_t *values = new Int_t[fSizePNEId];
3481 memset(values, 0, fSizePNEId * sizeof(Int_t));
3482 // Copy all keys<uid in the new keys array (0 to index)
3483 memcpy(keys, fKeyPNEId, (index + 1) * sizeof(Int_t));
3484 memcpy(values, fValuePNEId, (index + 1) * sizeof(Int_t));
3485 // Insert current key at index+1
3486 keys[index + 1] = uid;
3487 values[index + 1] = ientry;
3488 // Copy all remaining keys from the old to new array
3489 memcpy(&keys[index + 2], &fKeyPNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3490 memcpy(&values[index + 2], &fValuePNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3491 delete[] fKeyPNEId;
3492 fKeyPNEId = keys;
3493 delete[] fValuePNEId;
3494 fValuePNEId = values;
3495 fNPNEId++;
3496 return kTRUE;
3497 }
3498 // Insert the value in the existing arrays
3499 Int_t i;
3500 for (i = fNPNEId - 1; i > index; i--) {
3501 fKeyPNEId[i + 1] = fKeyPNEId[i];
3502 fValuePNEId[i + 1] = fValuePNEId[i];
3503 }
3504 fKeyPNEId[index + 1] = uid;
3505 fValuePNEId[index + 1] = ientry;
3506 fNPNEId++;
3507 return kTRUE;
3508}
3509
3510////////////////////////////////////////////////////////////////////////////////
3511/// Make a physical node from the path pointed by an alignable object with a given name.
3512
3514{
3516 if (!entry) {
3517 Error("MakeAlignablePN", "No alignable object named %s found !", name);
3518 return nullptr;
3519 }
3520 return MakeAlignablePN(entry);
3521}
3522
3523////////////////////////////////////////////////////////////////////////////////
3524/// Make a physical node from the path pointed by a given alignable object.
3525
3527{
3528 if (!entry) {
3529 Error("MakeAlignablePN", "No alignable object specified !");
3530 return nullptr;
3531 }
3532 const char *path = entry->GetTitle();
3533 if (!cd(path)) {
3534 Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s", entry->GetName(), path);
3535 return nullptr;
3536 }
3537 TGeoPhysicalNode *node = MakePhysicalNode(path);
3538 entry->SetPhysicalNode(node);
3539 return node;
3540}
3541
3542////////////////////////////////////////////////////////////////////////////////
3543/// Makes a physical node corresponding to a path. If PATH is not specified,
3544/// makes physical node matching current modeller state.
3545
3547{
3548 TGeoPhysicalNode *node;
3549 if (path) {
3550 if (!CheckPath(path)) {
3551 Error("MakePhysicalNode", "path: %s not valid", path);
3552 return nullptr;
3553 }
3554 node = new TGeoPhysicalNode(path);
3555 } else {
3556 node = new TGeoPhysicalNode(GetPath());
3557 }
3558 fPhysicalNodes->Add(node);
3559 return node;
3560}
3561
3562////////////////////////////////////////////////////////////////////////////////
3563/// Refresh physical nodes to reflect the actual geometry paths after alignment
3564/// was applied. Optionally locks physical nodes (default).
3565
3567{
3570 while ((pn = (TGeoPhysicalNode *)next()))
3571 pn->Refresh();
3574 if (lock)
3575 LockGeometry();
3576}
3577
3578////////////////////////////////////////////////////////////////////////////////
3579/// Clear the current list of physical nodes, so that we can start over with a new list.
3580/// If MUSTDELETE is true, delete previous nodes.
3581
3589
3590////////////////////////////////////////////////////////////////////////////////
3591/// Make an assembly of volumes.
3592
3594{
3595 return TGeoBuilder::Instance(this)->MakeVolumeAssembly(name);
3596}
3597
3598////////////////////////////////////////////////////////////////////////////////
3599/// Make a TGeoVolumeMulti handling a list of volumes.
3600
3602{
3603 return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3604}
3605
3606////////////////////////////////////////////////////////////////////////////////
3607/// Set type of exploding view (see TGeoPainter::SetExplodedView())
3608
3610{
3611 if ((ibomb >= 0) && (ibomb < 4))
3613 if (fPainter)
3615}
3616
3617////////////////////////////////////////////////////////////////////////////////
3618/// Set cut phi range
3619
3621{
3622 if ((phimin == 0) && (phimax == 360)) {
3623 fPhiCut = kFALSE;
3624 return;
3625 }
3626 fPhiCut = kTRUE;
3627 fPhimin = phimin;
3628 fPhimax = phimax;
3629}
3630
3631////////////////////////////////////////////////////////////////////////////////
3632/// Set number of segments for approximating circles in drawing.
3633
3635{
3636 if (fNsegments == nseg)
3637 return;
3638 if (nseg > 2)
3639 fNsegments = nseg;
3640 if (fPainter)
3643}
3644
3645////////////////////////////////////////////////////////////////////////////////
3646/// Get number of segments approximating circles
3647
3649{
3650 return fNsegments;
3651}
3652
3653////////////////////////////////////////////////////////////////////////////////
3654/// Invalidate mesh caches built by composite shapes
3655
3657{
3659 TGeoShape *shape;
3660 while ((shape = (TGeoShape *)next_shape())) {
3661 if (shape->IsComposite())
3662 ((TGeoCompositeShape *)shape)->InvalidateMeshCaches();
3663 }
3664}
3665
3666////////////////////////////////////////////////////////////////////////////////
3667/// Now just a shortcut for GetElementTable.
3668
3674
3675////////////////////////////////////////////////////////////////////////////////
3676/// Returns material table. Creates it if not existing.
3677
3684
3685////////////////////////////////////////////////////////////////////////////////
3686/// Make a rectilinear step of length fStep from current point (fPoint) on current
3687/// direction (fDirection). If the step is imposed by geometry, is_geom flag
3688/// must be true (default). The cross flag specifies if the boundary should be
3689/// crossed in case of a geometry step (default true). Returns new node after step.
3690/// Set also on boundary condition.
3691
3693{
3694 return GetCurrentNavigator()->Step(is_geom, cross);
3695}
3696
3697////////////////////////////////////////////////////////////////////////////////
3698/// shoot npoints randomly in a box of 1E-5 around current point.
3699/// return minimum distance to points outside
3700
3705
3706////////////////////////////////////////////////////////////////////////////////
3707/// Set the top volume and corresponding node as starting point of the geometry.
3708
3710{
3711 if (fTopVolume == vol)
3712 return;
3713
3714 TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3715 TIter next(brlist);
3716 TBrowser *browser = nullptr;
3717
3718 if (fTopVolume)
3719 fTopVolume->SetTitle("");
3720 fTopVolume = vol;
3721 vol->SetTitle("Top volume");
3722 if (fTopNode) {
3724 fTopNode = nullptr;
3725 while ((browser = (TBrowser *)next()))
3726 browser->RecursiveRemove(topn);
3727 delete topn;
3728 } else {
3729 fMasterVolume = vol;
3732 if (fgVerboseLevel > 0)
3733 Info("SetTopVolume", "Top volume is %s. Master volume is %s", fTopVolume->GetName(), fMasterVolume->GetName());
3734 }
3735 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3736 // fCurrentMatrix->Print();
3738 fTopNode->SetName(TString::Format("%s_1", vol->GetName()));
3739 fTopNode->SetNumber(1);
3740 fTopNode->SetTitle("Top logical node");
3741 fNodes->AddAt(fTopNode, 0);
3742 if (!GetCurrentNavigator()) {
3744 return;
3745 }
3746 Int_t nnavigators = 0;
3748 if (!arr)
3749 return;
3750 nnavigators = arr->GetEntriesFast();
3751 for (Int_t i = 0; i < nnavigators; i++) {
3752 TGeoNavigator *nav = (TGeoNavigator *)arr->At(i);
3753 nav->ResetAll();
3754 if (fClosed)
3755 nav->GetCache()->BuildInfoBranch();
3756 }
3757}
3758
3759////////////////////////////////////////////////////////////////////////////////
3760/// Define different tracking media.
3761
3763{
3764 /*
3765 Int_t nmat = fMaterials->GetSize();
3766 if (!nmat) {printf(" No materials !\n"); return;}
3767 Int_t *media = new Int_t[nmat];
3768 memset(media, 0, nmat*sizeof(Int_t));
3769 Int_t imedia = 1;
3770 TGeoMaterial *mat, *matref;
3771 mat = (TGeoMaterial*)fMaterials->At(0);
3772 if (mat->GetMedia()) {
3773 for (Int_t i=0; i<nmat; i++) {
3774 mat = (TGeoMaterial*)fMaterials->At(i);
3775 mat->Print();
3776 }
3777 return;
3778 }
3779 mat->SetMedia(imedia);
3780 media[0] = imedia++;
3781 mat->Print();
3782 for (Int_t i=0; i<nmat; i++) {
3783 mat = (TGeoMaterial*)fMaterials->At(i);
3784 for (Int_t j=0; j<i; j++) {
3785 matref = (TGeoMaterial*)fMaterials->At(j);
3786 if (mat->IsEq(matref)) {
3787 mat->SetMedia(media[j]);
3788 break;
3789 }
3790 if (j==(i-1)) {
3791 // different material
3792 mat->SetMedia(imedia);
3793 media[i] = imedia++;
3794 mat->Print();
3795 }
3796 }
3797 }
3798 */
3799}
3800
3801////////////////////////////////////////////////////////////////////////////////
3802/// Check pushes and pulls needed to cross the next boundary with respect to the
3803/// position given by FindNextBoundary. If radius is not mentioned the full bounding
3804/// box will be sampled.
3805
3810
3811////////////////////////////////////////////////////////////////////////////////
3812/// Check the boundary errors reference file created by CheckBoundaryErrors method.
3813/// The shape for which the crossing failed is drawn with the starting point in red
3814/// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3815
3820
3821////////////////////////////////////////////////////////////////////////////////
3822/// Classify a given point. See TGeoChecker::CheckPoint().
3823
3828
3829////////////////////////////////////////////////////////////////////////////////
3830/// Test for shape navigation methods. Summary for test numbers:
3831/// - 1: DistFromInside/Outside. Sample points inside the shape. Generate
3832/// directions randomly in cos(theta). Compute DistFromInside and move the
3833/// point with bigger distance. Compute DistFromOutside back from new point.
3834/// Plot d-(d1+d2)
3835///
3836
3841
3842////////////////////////////////////////////////////////////////////////////////
3843/// Geometry checking.
3844/// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3845/// - if option contains 'b': Optional boundary crossing check + timing per volume.
3846///
3847/// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3848/// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3849/// be called for the suspicious volumes.
3850///
3851/// STAGE 2: normal overlap checking using the shapes mesh - fills the list of
3852/// overlaps.
3853///
3854/// STAGE 3: shooting NRAYS rays from VERTEX and counting the total number of
3855/// crossings per volume (rays propagated from boundary to boundary until
3856/// geometry exit). Timing computed and results stored in a histo.
3857///
3858/// STAGE 4: shooting 1 mil. random rays inside EACH volume and calling
3859/// FindNextBoundary() + Safety() for each call. The timing is normalized by the
3860/// number of crossings computed at stage 2 and presented as percentage.
3861/// One can get a picture on which are the most "burned" volumes during
3862/// transportation from geometry point of view. Another plot of the timing per
3863/// volume vs. number of daughters is produced.
3864
3866{
3867 TString opt(option);
3868 opt.ToLower();
3869 if (!opt.Length()) {
3870 Error("CheckGeometryFull", "The option string must contain a letter. See method documentation.");
3871 return;
3872 }
3873 Bool_t checkoverlaps = opt.Contains("o");
3874 Bool_t checkcrossings = opt.Contains("b");
3875 Double_t vertex[3];
3876 vertex[0] = vx;
3877 vertex[1] = vy;
3878 vertex[2] = vz;
3880}
3881
3882////////////////////////////////////////////////////////////////////////////////
3883/// Perform last checks on the geometry
3884
3886{
3887 if (fgVerboseLevel > 0)
3888 Info("CheckGeometry", "Fixing runtime shapes...");
3889 TIter next(fShapes);
3891 TGeoShape *shape;
3892 TGeoVolume *vol;
3894 while ((shape = (TGeoShape *)next())) {
3895 if (shape->IsRunTimeShape()) {
3897 }
3898 if (fIsGeomReading)
3899 shape->AfterStreamer();
3902 shape->ComputeBBox();
3903 }
3904 if (has_runtime)
3906 else if (fgVerboseLevel > 0)
3907 Info("CheckGeometry", "...Nothing to fix");
3908 // Compute bounding box for assemblies
3910 while ((vol = (TGeoVolume *)nextv())) {
3911 if (vol->IsAssembly())
3912 vol->GetShape()->ComputeBBox();
3913 else if (vol->GetMedium() == dummy) {
3914 Warning("CheckGeometry", "Volume \"%s\" has no medium: assigned dummy medium and material", vol->GetName());
3915 vol->SetMedium(dummy);
3916 }
3917 }
3918}
3919
3920////////////////////////////////////////////////////////////////////////////////
3921/// Check all geometry for illegal overlaps within a limit OVLP.
3922
3924{
3925 if (!fTopNode) {
3926 Error("CheckOverlaps", "Top node not set");
3927 return;
3928 }
3930}
3931
3932////////////////////////////////////////////////////////////////////////////////
3933/// Check all geometry for illegal overlaps within a limit OVLP.
3934
3936{
3937 if (!fTopNode) {
3938 Error("CheckOverlaps", "Top node not set");
3939 return;
3940 }
3942}
3943
3944////////////////////////////////////////////////////////////////////////////////
3945/// Prints the current list of overlaps.
3946
3948{
3949 if (!fOverlaps)
3950 return;
3952 if (!novlp)
3953 return;
3954 TGeoManager *geom = (TGeoManager *)this;
3955 geom->GetGeomChecker()->PrintOverlaps();
3956}
3957
3958////////////////////////////////////////////////////////////////////////////////
3959/// Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
3960/// Option can be "v" - verbose (default)
3961
3963{
3964 if (!GetGeomChecker())
3965 return 0.;
3966 TString opt(option);
3967 opt.ToLower();
3968 Double_t weight;
3969 TGeoVolume *volume = fTopVolume;
3970 if (opt.Contains("v")) {
3971 if (opt.Contains("a")) {
3972 if (fgVerboseLevel > 0)
3973 Info("Weight", "Computing analytically weight of %s", volume->GetName());
3974 weight = volume->WeightA();
3975 if (fgVerboseLevel > 0)
3976 Info("Weight", "Computed weight: %f [kg]\n", weight);
3977 return weight;
3978 }
3979 if (fgVerboseLevel > 0) {
3980 Info("Weight", "Estimating weight of %s with %g %% precision", fTopVolume->GetName(), 100. * precision);
3981 printf(" event weight err\n");
3982 printf("========================================\n");
3983 }
3984 }
3985 weight = fChecker->Weight(precision, option);
3986 return weight;
3987}
3988
3989////////////////////////////////////////////////////////////////////////////////
3990/// computes the total size in bytes of the branch starting with node.
3991/// The option can specify if all the branch has to be parsed or only the node
3992
3993ULong_t TGeoManager::SizeOf(const TGeoNode * /*node*/, Option_t * /*option*/)
3994{
3995 return 0;
3996}
3997
3998////////////////////////////////////////////////////////////////////////////////
3999/// Stream an object of class TGeoManager.
4000
4002{
4003 if (R__b.IsReading()) {
4004 R__b.ReadClassBuffer(TGeoManager::Class(), this);
4006 CloseGeometry();
4009 } else {
4010 R__b.WriteClassBuffer(TGeoManager::Class(), this);
4011 }
4012}
4013
4014////////////////////////////////////////////////////////////////////////////////
4015/// Execute mouse actions on this manager.
4016
4018{
4019 if (!fPainter)
4020 return;
4021 fPainter->ExecuteManagerEvent(this, event, px, py);
4022}
4023
4024////////////////////////////////////////////////////////////////////////////////
4025/// Export this geometry to a file
4026///
4027/// - Case 1: root file or root/xml file
4028/// if filename end with ".root". The key will be named name
4029/// By default the geometry is saved without the voxelisation info.
4030/// Use option 'v" to save the voxelisation info.
4031/// if filename end with ".xml" a root/xml file is produced.
4032///
4033/// - Case 2: C++ script
4034/// if filename end with ".C"
4035///
4036/// - Case 3: gdml file
4037/// if filename end with ".gdml"
4038/// NOTE that to use this option, the PYTHONPATH must be defined like
4039/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/geom/gdml
4040///
4041
4043{
4045 if (sfile.Contains(".C")) {
4046 // Save geometry as a C++ script
4047 if (fgVerboseLevel > 0)
4048 Info("Export", "Exporting %s %s as C++ code", GetName(), GetTitle());
4050 return 1;
4051 }
4052 if (sfile.Contains(".gdml")) {
4053 // Save geometry as a gdml file
4054 if (fgVerboseLevel > 0)
4055 Info("Export", "Exporting %s %s as gdml code", GetName(), GetTitle());
4056 // C++ version
4057 TString cmd;
4058 cmd = TString::Format("TGDMLWrite::StartGDMLWriting(gGeoManager,\"%s\",\"%s\")", filename, option);
4059 gROOT->ProcessLineFast(cmd);
4060 return 1;
4061 }
4062 if (sfile.Contains(".root") || sfile.Contains(".xml")) {
4063 // Save geometry as a root file
4064 TFile *f = TFile::Open(filename, "recreate");
4065 if (!f || f->IsZombie()) {
4066 Error("Export", "Cannot open file");
4067 return 0;
4068 }
4070 if (keyname.IsNull())
4071 keyname = GetName();
4072 TString opt = option;
4073 opt.ToLower();
4074 if (opt.Contains("v")) {
4076 if (fgVerboseLevel > 0)
4077 Info("Export", "Exporting %s %s as root file. Optimizations streamed.", GetName(), GetTitle());
4078 } else {
4080 if (fgVerboseLevel > 0)
4081 Info("Export", "Exporting %s %s as root file. Optimizations not streamed.", GetName(), GetTitle());
4082 }
4083
4087 if (sfile.Contains(".xml")) {
4090 }
4092 if (sfile.Contains(".xml")) {
4095 }
4096
4098 delete f;
4099 return nbytes;
4100 }
4101 return 0;
4102}
4103
4104////////////////////////////////////////////////////////////////////////////////
4105/// Lock current geometry so that no other geometry can be imported.
4106
4108{
4109 fgLock = kTRUE;
4110}
4111
4112////////////////////////////////////////////////////////////////////////////////
4113/// Unlock current geometry.
4114
4116{
4117 fgLock = kFALSE;
4118}
4119
4120////////////////////////////////////////////////////////////////////////////////
4121/// Check lock state.
4122
4124{
4125 return fgLock;
4126}
4127
4128////////////////////////////////////////////////////////////////////////////////
4129/// Set verbosity level (static function).
4130/// - 0 - suppress messages related to geom-painter visibility level
4131/// - 1 - default value
4132
4137
4138////////////////////////////////////////////////////////////////////////////////
4139/// Return current verbosity level (static function).
4140
4145
4146////////////////////////////////////////////////////////////////////////////////
4147/// static function
4148/// Import a geometry from a gdml or ROOT file
4149///
4150/// - Case 1: gdml
4151/// if filename ends with ".gdml" the foreign geometry described with gdml
4152/// is imported executing some python scripts in $ROOTSYS/gdml.
4153/// NOTE that to use this option, the PYTHONPATH must be defined like
4154/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
4155///
4156/// - Case 2: root file (.root) or root/xml file (.xml)
4157/// Import in memory from filename the geometry with key=name.
4158/// if name="" (default), the first TGeoManager object in the file is returned.
4159///
4160/// Note that this function deletes the current gGeoManager (if one)
4161/// before importing the new object.
4162
4163TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
4164{
4165 if (fgLock) {
4166 ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
4167 return nullptr;
4168 }
4169 if (!filename)
4170 return nullptr;
4171 if (fgVerboseLevel > 0)
4172 ::Info("TGeoManager::Import", "Reading geometry from file: %s", filename);
4173
4174 if (gGeoManager)
4175 delete gGeoManager;
4176 gGeoManager = nullptr;
4177
4178 if (strstr(filename, ".gdml")) {
4179 // import from a gdml file
4180 new TGeoManager("GDMLImport", "Geometry imported from GDML");
4181 TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
4182 TGeoVolume *world = (TGeoVolume *)gROOT->ProcessLineFast(cmd);
4183
4184 if (world == nullptr) {
4185 delete gGeoManager;
4186 gGeoManager = nullptr;
4187 ::Error("TGeoManager::Import", "Cannot read file %s", filename);
4188 } else {
4192 }
4193 } else {
4194 // import from a root file
4196 // in case a web file is specified, use the cacheread option to cache
4197 // this file in the cache directory
4198 TFile *f = nullptr;
4199 if (strstr(filename, "http"))
4200 f = TFile::Open(filename, "CACHEREAD");
4201 else
4203 if (!f || f->IsZombie()) {
4204 ::Error("TGeoManager::Import", "Cannot open file");
4205 return nullptr;
4206 }
4207 if (name && strlen(name) > 0) {
4208 gGeoManager = (TGeoManager *)f->Get(name);
4209 } else {
4210 TIter next(f->GetListOfKeys());
4211 TKey *key;
4212 while ((key = (TKey *)next())) {
4213 if (strcmp(key->GetClassName(), "TGeoManager") != 0)
4214 continue;
4215 gGeoManager = (TGeoManager *)key->ReadObj();
4216 break;
4217 }
4218 }
4219 delete f;
4220 }
4221 if (!gGeoManager)
4222 return nullptr;
4223 if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager))
4224 gROOT->GetListOfGeometries()->Add(gGeoManager);
4225 if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager))
4226 gROOT->GetListOfBrowsables()->Add(gGeoManager);
4228 return gGeoManager;
4229}
4230
4231////////////////////////////////////////////////////////////////////////////////
4232/// Update element flags when geometry is loaded from a file.
4233
4235{
4236 if (!fElementTable)
4237 return;
4238 TIter next(fMaterials);
4240 TGeoMixture *mix;
4242 Int_t i, nelem;
4243 while ((mat = (TGeoMaterial *)next())) {
4244 if (mat->IsMixture()) {
4245 mix = (TGeoMixture *)mat;
4246 nelem = mix->GetNelements();
4247 for (i = 0; i < nelem; i++) {
4248 elem = mix->GetElement(i);
4249 if (!elem)
4250 continue;
4252 if (!elem_table)
4253 continue;
4254 if (elem != elem_table) {
4255 elem_table->SetDefined(elem->IsDefined());
4256 elem_table->SetUsed(elem->IsUsed());
4257 } else {
4258 elem_table->SetDefined();
4259 }
4260 }
4261 } else {
4262 elem = mat->GetElement();
4263 if (!elem)
4264 continue;
4266 if (!elem_table)
4267 continue;
4268 if (elem != elem_table) {
4269 elem_table->SetDefined(elem->IsDefined());
4270 elem_table->SetUsed(elem->IsUsed());
4271 } else {
4272 elem_table->SetUsed();
4273 }
4274 }
4275 }
4276}
4277
4278////////////////////////////////////////////////////////////////////////////////
4279/// Initialize PNE array for fast access via index and unique-id.
4280
4282{
4283 if (fHashPNE) {
4285 TIter next(fHashPNE);
4286 TObject *obj;
4287 while ((obj = next())) {
4288 fArrayPNE->Add(obj);
4289 }
4290 return kTRUE;
4291 }
4292 return kFALSE;
4293}
4294
4295////////////////////////////////////////////////////////////////////////////////
4296/// Get time cut for drawing tracks.
4297
4299{
4300 tmin = fTmin;
4301 tmax = fTmax;
4302 return fTimeCut;
4303}
4304
4305////////////////////////////////////////////////////////////////////////////////
4306/// Set time cut interval for drawing tracks. If called with no arguments, time
4307/// cut will be disabled.
4308
4310{
4311 fTmin = tmin;
4312 fTmax = tmax;
4313 if (tmin == 0 && tmax == 999)
4314 fTimeCut = kFALSE;
4315 else
4316 fTimeCut = kTRUE;
4317 if (fTracks && !IsAnimatingTracks())
4318 ModifiedPad();
4319}
4320
4321////////////////////////////////////////////////////////////////////////////////
4322/// Convert coordinates from master volume frame to top.
4323
4328
4329////////////////////////////////////////////////////////////////////////////////
4330/// Convert coordinates from top volume frame to master.
4331
4336
4337////////////////////////////////////////////////////////////////////////////////
4338/// Create a parallel world for prioritised navigation. This can be populated
4339/// with physical nodes and can be navigated independently using its API.
4340/// In case the flag SetUseParallelWorldNav is set, any navigation query in the
4341/// main geometry is checked against the parallel geometry, which gets priority
4342/// in case of overlaps with the main geometry volumes.
4343
4349
4350////////////////////////////////////////////////////////////////////////////////
4351/// Activate/deactivate usage of parallel world navigation. Can only be done if
4352/// there is a parallel world. Activating navigation will automatically close
4353/// the parallel geometry.
4354
4356{
4357 if (!fParallelWorld) {
4358 Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
4359 return;
4360 }
4361 if (!flag) {
4362 fUsePWNav = flag;
4363 return;
4364 }
4365 if (!fClosed) {
4366 Error("SetUseParallelWorldNav", "The geometry must be closed first");
4367 return;
4368 }
4369 // Closing the parallel world geometry is mandatory
4371 fUsePWNav = kTRUE;
4372}
4373
4380
4385
4387{
4388 if (fgDefaultUnits == new_value) {
4389 gGeometryLocked = true;
4390 return;
4391 } else if (gGeometryLocked) {
4392 ::Fatal("TGeoManager", "The system of units may only be changed once, \n"
4393 "BEFORE any elements and materials are created! \n"
4394 "Alternatively unlock the default units at own risk.");
4395 } else if (new_value == kG4Units) {
4396 ::Info("TGeoManager", "Changing system of units to Geant4 units (mm, ns, MeV).");
4397 } else if (new_value == kRootUnits) {
4398 ::Info("TGeoManager", "Changing system of units to ROOT units (cm, s, GeV).");
4399 }
4401}
4402
4407
#define SafeDelete(p)
Definition RConfig.hxx:535
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#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
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define BIT(n)
Definition Rtypes.h:91
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
@ kNatural
Natural, material-inspired colors (default)
TGeoManager * gGeoManager
static Bool_t gGeometryLocked
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TGeoIdentity * gGeoIdentity
Definition TGeoMatrix.h:538
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:5944
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:101
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:503
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:130
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:3764
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:127
void SetVisTouched(Bool_t vis=kTRUE)
Mark visualization attributes as "modified".
Definition TGeoAtt.cxx:137
void SetVisBranch()
Set branch type visibility.
Definition TGeoAtt.cxx:65
Box class.
Definition TGeoBBox.h:18
static TGeoBuilder * Instance(TGeoManager *geom)
Return pointer to singleton.
Strategy object for assigning colors and transparency to geometry volumes.
Class describing rotation + translation.
Definition TGeoMatrix.h:318
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:459
An identity transformation.
Definition TGeoMatrix.h:407
A geometry iterator.
Definition TGeoNode.h:249
Int_t GetLevel() const
Definition TGeoNode.h:295
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
static void UnlockGeometry()
Unlock current geometry.
Double_t fPhimax
lowest range for phi cut
Definition TGeoManager.h:68
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:74
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:79
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:56
void Init()
Initialize manager class.
Bool_t InitArrayPNE() const
Initialize PNE array for fast access via index and unique-id.
TObjArray * fPhysicalNodes
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:60
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
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.
void CheckOverlapsBySampling(Double_t ovlp, Int_t npoints)
Check all geometry for illegal overlaps within a limit OVLP.
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
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:90
static void SetExportPrecision(UInt_t prec)
void AddBorderSurface(TGeoBorderSurface *surf)
Add border surface;.
void RebuildVoxels()
Rebuild the voxel structures that are flagged as needing rebuild.
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:97
Int_t fVisOption
Definition TGeoManager.h:76
static std::mutex fgMutex
Definition TGeoManager.h:54
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:67
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:91
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:99
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:69
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:55
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
void AddOpticalSurface(TGeoOpticalSurface *optsurf)
Add optical surface;.
static void SetDefaultUnits(EDefaultUnits new_value)
Bool_t fLoopVolumes
flag that geometry is closed
Definition TGeoManager.h:85
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:58
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:87
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:96
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:95
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:94
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:71
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:88
void DefaultColors(const TGeoColorScheme *cs=nullptr)
Set default volume colors according to A of material.
Bool_t IsSameLocation() const
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:59
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:57
Int_t fNpdg
current track
Definition TGeoManager.h:82
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:92
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:93
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:80
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:77
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:89
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:78
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:70
void InvalidateMeshCaches()
Invalidate mesh caches built by composite shapes.
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:61
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:75
Bool_t fClosed
Definition TGeoManager.h:84
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:81
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:83
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:86
Base class describing materials.
Geometrical transformation package.
Definition TGeoMatrix.h:39
@ kGeoSavePrimitive
Definition TGeoMatrix.h:49
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:155
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:108
TGeoVolume * GetVolume() const
Definition TGeoNode.h:100
void SaveAttributes(std::ostream &out)
save attributes for this node
Definition TGeoNode.cxx:567
void SetVolume(TGeoVolume *volume)
Definition TGeoNode.h:118
void CheckOverlapsBySampling(Double_t ovlp=0.1, Int_t npoints=1000000)
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition TGeoNode.cxx:198
void CheckShapes()
check for wrong parameters in shapes
Definition TGeoNode.cxx:457
void SetOverlapping(Bool_t flag=kTRUE)
Definition TGeoNode.h:121
Int_t GetNdaughters() const
Definition TGeoNode.h:92
virtual TGeoMatrix * GetMatrix() const =0
void SetVisibility(Bool_t vis=kTRUE) override
Set visibility of the node (obsolete).
Definition TGeoNode.cxx:846
void SetMotherVolume(TGeoVolume *mother)
Definition TGeoNode.h:126
static TClass * Class()
TGeoVolume * GetMotherVolume() const
Definition TGeoNode.h:91
void SetNumber(Int_t number)
Definition TGeoNode.h:119
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition TGeoNode.cxx:246
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:139
Bool_t IsRunTimeShape() const
Definition TGeoShape.h:152
virtual void ComputeBBox()=0
virtual void AfterStreamer()
Definition TGeoShape.h:101
@ kGeoClosedShape
Definition TGeoShape.h:59
TClass * IsA() const override
Definition TGeoShape.h:181
Bool_t TestShapeBit(UInt_t f) const
Definition TGeoShape.h:177
Volume assemblies.
Definition TGeoVolume.h:317
static TGeoVolumeAssembly * MakeAssemblyFromVolume(TGeoVolume *vol)
Make a clone of volume VOL but which is an assembly.
Volume families.
Definition TGeoVolume.h:267
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:246
void SetLineWidth(Width_t lwidth) override
Set the line width.
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:176
Int_t GetRefCount() const
Definition TGeoVolume.h:132
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:110
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:111
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:245
Int_t GetNdaughters() const
Definition TGeoVolume.h:363
void Grab()
Definition TGeoVolume.h:137
static TClass * Class()
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:378
void Release()
Definition TGeoVolume.h:138
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:243
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:185
TGeoShape * GetShape() const
Definition TGeoVolume.h:191
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:232
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:156
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:94
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:760
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
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:173
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:149
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:170
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:90
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:202
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1074
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:981
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:881
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:1088
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1116
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:892
virtual TClass * IsA() const
Definition TObject.h:246
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1062
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:865
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:138
Ssiz_t Length() const
Definition TString.h:425
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189
const char * Data() const
Definition TString.h:384
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:2384
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
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
void SetNmeshPoints(Int_t npoints=1000)
Set number of points to be generated on the shape outline when checking for overlaps.
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 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
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:506
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:657
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:329
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:75