Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoManager.cxx
Go to the documentation of this file.
1// @(#)root/geom:$Id$
2// Author: Andrei Gheata 25/10/01
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TGeoManager
13\ingroup Geometry_classes
14
15The manager class for any TGeo geometry. Provides user
16interface for geometry creation, navigation, state querying,
17visualization, IO, geometry checking and other utilities.
18
19## General architecture
20
21 The ROOT geometry package is a tool designed for building, browsing,
22tracking and visualizing a detector geometry. The code is independent from
23other external MC for simulation, therefore it does not contain any
24constraints related to physics. However, the package defines a number of
25hooks for tracking, such as media, materials, magnetic field or track state flags,
26in order to allow interfacing to tracking MC's. The final goal is to be
27able to use the same geometry for several purposes, such as tracking,
28reconstruction or visualization, taking advantage of the ROOT features
29related to bookkeeping, I/O, histogramming, browsing and GUI's.
30
31 The geometrical modeler is the most important component of the package and
32it provides answers to the basic questions like "Where am I ?" or "How far
33from the next boundary ?", but also to more complex ones like "How far from
34the closest surface ?" or "Which is the next crossing along a helix ?".
35
36 The architecture of the modeler is a combination between a GEANT-like
37containment scheme and a normal CSG binary tree at the level of shapes. An
38important common feature of all detector geometry descriptions is the
39mother-daughter concept. This is the most natural approach when tracking
40is concerned and imposes a set of constraints to the way geometry is defined.
41Constructive solid geometry composition is used only in order to create more
42complex shapes from an existing set of primitives through boolean operations.
43This feature is not implemented yet but in future full definition of boolean
44expressions will be supported.
45
46 Practically every geometry defined in GEANT style can be mapped by the modeler.
47The basic components used for building the logical hierarchy of the geometry
48are called "volumes" and "nodes". Volumes (sometimes called "solids") are fully
49defined geometrical objects having a given shape and medium and possibly
50containing a list of nodes. Nodes represent just positioned instances of volumes
51inside a container volume and they are not directly defined by user. They are
52automatically created as a result of adding one volume inside other or dividing
53a volume. The geometrical transformation hold by nodes is always defined with
54respect to their mother (relative positioning). Reflection matrices are allowed.
55All volumes have to be fully aware of their containees when the geometry is
56closed. They will build additional structures (voxels) in order to fasten-up
57the search algorithms. Finally, nodes can be regarded as bidirectional links
58between containers and containees objects.
59
60 The structure defined in this way is a graph structure since volumes are
61replicable (same volume can become daughter node of several other volumes),
62every volume becoming a branch in this graph. Any volume in the logical graph
63can become the actual top volume at run time (see TGeoManager::SetTopVolume()).
64All functionalities of the modeler will behave in this case as if only the
65corresponding branch starting from this volume is the registered geometry.
66
67\image html geom_graf.jpg
68
69 A given volume can be positioned several times in the geometry. A volume
70can be divided according default or user-defined patterns, creating automatically
71the list of division nodes inside. The elementary volumes created during the
72dividing process follow the same scheme as usual volumes, therefore it is possible
73to position further geometrical structures inside or to divide them further more
74(see TGeoVolume::Divide()).
75
76 The primitive shapes supported by the package are basically the GEANT3
77shapes (see class TGeoShape), arbitrary wedges with eight vertices on two parallel
78planes. All basic primitives inherits from class TGeoBBox since the bounding box
79of a solid is essential for the tracking algorithms. They also implement the
80virtual methods defined in the virtual class TGeoShape (point and segment
81classification). User-defined primitives can be directly plugged into the modeler
82provided that they override these methods. Composite shapes will be soon supported
83by the modeler. In order to build a TGeoCompositeShape, one will have to define
84first the primitive components. The object that handle boolean
85operations among components is called TGeoBoolCombinator and it has to be
86constructed providing a string boolean expression between the components names.
87
88
89## Example for building a simple geometry
90
91Begin_Macro(source)
92../../../tutorials/visualisation/geom/rootgeom.C
93End_Macro
94
95## TGeoManager - the manager class for the geometry package.
96
97 TGeoManager class is embedding all the API needed for building and tracking
98a geometry. It defines a global pointer (gGeoManager) in order to be fully
99accessible from external code. The mechanism of handling multiple geometries
100at the same time will be soon implemented.
101
102 TGeoManager is the owner of all geometry objects defined in a session,
103therefore users must not try to control their deletion. It contains lists of
104media, materials, transformations, shapes and volumes. Logical nodes (positioned
105volumes) are created and destroyed by the TGeoVolume class. Physical
106nodes and their global transformations are subjected to a caching mechanism
107due to the sometimes very large memory requirements of logical graph expansion.
108The caching mechanism is triggered by the total number of physical instances
109of volumes and the cache manager is a client of TGeoManager. The manager class
110also controls the painter client. This is linked with ROOT graphical libraries
111loaded on demand in order to control visualization actions.
112
113## Rules for building a valid geometry
114
115 A given geometry can be built in various ways, but there are mandatory steps
116that have to be followed in order to be validated by the modeler. There are
117general rules : volumes needs media and shapes in order to be created,
118both container and containee volumes must be created before linking them together,
119and the relative transformation matrix must be provided. All branches must
120have an upper link point otherwise they will not be considered as part of the
121geometry. Visibility or tracking properties of volumes can be provided both
122at build time or after geometry is closed, but global visualization settings
123(see TGeoPainter class) should not be provided at build time, otherwise the
124drawing package will be loaded. There is also a list of specific rules :
125positioned daughters should not extrude their mother or intersect with sisters
126unless this is specified (see TGeoVolume::AddNodeOverlap()), the top volume
127(containing all geometry tree) must be specified before closing the geometry
128and must not be positioned - it represents the global reference frame. After
129building the full geometry tree, the geometry must be closed
130(see TGeoManager::CloseGeometry()). Voxelization can be redone per volume after
131this process.
132
133
134 Below is the general scheme of the manager class.
135
136\image html geom_mgr.jpg
137
138## An interactive session
139
140 Provided that a geometry was successfully built and closed (for instance the
141previous example rootgeom.C ), the manager class will register
142itself to ROOT and the logical/physical structures will become immediately browsable.
143The ROOT browser will display starting from the geometry folder : the list of
144transformations and media, the top volume and the top logical node. These last
145two can be fully expanded, any intermediate volume/node in the browser being subject
146of direct access context menu operations (right mouse button click). All user
147utilities of classes TGeoManager, TGeoVolume and TGeoNode can be called via the
148context menu.
149
150\image html geom_browser.jpg
151
152### Drawing the geometry
153
154 Any logical volume can be drawn via TGeoVolume::Draw() member function.
155This can be directly accessed from the context menu of the volume object
156directly from the browser.
157 There are several drawing options that can be set with
158TGeoManager::SetVisOption(Int_t opt) method :
159
160#### opt=0
161 only the content of the volume is drawn, N levels down (default N=3).
162 This is the default behavior. The number of levels to be drawn can be changed
163 via TGeoManager::SetVisLevel(Int_t level) method.
164
165\image html geom_frame0.jpg
166
167#### opt=1
168 the final leaves (e.g. daughters with no containment) of the branch
169 starting from volume are drawn down to the current number of levels.
170 WARNING : This mode is memory consuming
171 depending of the size of geometry, so drawing from top level within this mode
172 should be handled with care for expensive geometries. In future there will be
173 a limitation on the maximum number of nodes to be visualized.
174
175\image html geom_frame1.jpg
176
177#### opt=2
178 only the clicked volume is visualized. This is automatically set by
179 TGeoVolume::DrawOnly() method
180
181#### opt=3 - only a given path is visualized. This is automatically set by
182 TGeoVolume::DrawPath(const char *path) method
183
184 The current view can be exploded in cartesian, cylindrical or spherical
185coordinates :
186 TGeoManager::SetExplodedView(Int_t opt). Options may be :
187- 0 - default (no bombing)
188- 1 - cartesian coordinates. The bomb factor on each axis can be set with
189 TGeoManager::SetBombX(Double_t bomb) and corresponding Y and Z.
190- 2 - bomb in cylindrical coordinates. Only the bomb factors on Z and R
191 are considered
192 \image html geom_frameexp.jpg
193
194- 3 - bomb in radial spherical coordinate : TGeoManager::SetBombR()
195
196Volumes themselves support different visualization settings :
197 - TGeoVolume::SetVisibility() : set volume visibility.
198 - TGeoVolume::VisibleDaughters() : set daughters visibility.
199All these actions automatically updates the current view if any.
200
201### Checking the geometry
202
203 Several checking methods are accessible from the volume context menu. They
204generally apply only to the visible parts of the drawn geometry in order to
205ease geometry checking, and their implementation is in the TGeoChecker class
206from the painting package.
207
208#### Checking a given point.
209 Can be called from TGeoManager::CheckPoint(Double_t x, Double_t y, Double_t z).
210This method is drawing the daughters of the volume containing the point one
211level down, printing the path to the deepest physical node holding this point.
212It also computes the closest distance to any boundary. The point will be drawn
213in red, as well as a sphere having this closest distance as radius. In case a
214non-zero distance is given by the user as fifth argument of CheckPoint, this
215distance will be used as radius of the safety sphere.
216
217\image html geom_checkpoint.jpg
218
219#### Shooting random points.
220 Can be called from TGeoVolume::RandomPoints() (context menu function) and
221it will draw this volume with current visualization settings. Random points
222are generated in the bounding box of the top drawn volume. The points are
223classified and drawn with the color of their deepest container. Only points
224in visible nodes will be drawn.
225
226\image html geom_random1.jpg
227
228
229#### Raytracing.
230 Can be called from TGeoVolume::RandomRays() (context menu of volumes) and
231will shoot rays from a given point in the local reference frame with random
232directions. The intersections with displayed nodes will appear as segments
233having the color of the touched node. Drawn geometry will be then made invisible
234in order to enhance rays.
235
236\image html geom_random2.jpg
237*/
238
239#include <cstdlib>
240#include <iostream>
241#include <fstream>
242
243#include "TROOT.h"
244#include "TGeoManager.h"
245#include "TStyle.h"
246#include "TVirtualPad.h"
247#include "TBrowser.h"
248#include "TFile.h"
249#include "TKey.h"
250#include "THashList.h"
251#include "TClass.h"
252#include "ThreadLocalStorage.h"
253#include "TBufferText.h"
254
255#include "TGeoVoxelFinder.h"
256#include "TGeoElement.h"
257#include "TGeoMaterial.h"
258#include "TGeoMedium.h"
259#include "TGeoMatrix.h"
260#include "TGeoNode.h"
261#include "TGeoPhysicalNode.h"
262#include "TGeoPara.h"
263#include "TGeoParaboloid.h"
264#include "TGeoTube.h"
265#include "TGeoEltu.h"
266#include "TGeoHype.h"
267#include "TGeoCone.h"
268#include "TGeoSphere.h"
269#include "TGeoArb8.h"
270#include "TGeoPgon.h"
271#include "TGeoTrd1.h"
272#include "TGeoTrd2.h"
273#include "TGeoTorus.h"
274#include "TGeoXtru.h"
275#include "TGeoCompositeShape.h"
276#include "TGeoBoolNode.h"
277#include "TGeoBuilder.h"
278#include "TVirtualGeoPainter.h"
279#include "TVirtualGeoChecker.h"
280#include "TPluginManager.h"
281#include "TVirtualGeoTrack.h"
282#include "TQObject.h"
283#include "TMath.h"
284#include "TEnv.h"
285#include "TGeoParallelWorld.h"
286#include "TGeoRegion.h"
287#include "TGDMLMatrix.h"
288#include "TGeoOpticalSurface.h"
289
290// statics and globals
291
293
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/// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1205
1207{
1209 if (!toTransform) {
1210 Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1211 return 0;
1212 }
1214 Int_t count = 0;
1216 Bool_t replace = kTRUE;
1218 while (index < indmax) {
1219 if (replace) {
1220 replace = kFALSE;
1222 if (transformed) {
1224 count++;
1225 } else {
1226 if (toTransform->IsAssembly())
1227 Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1228 if (!toTransform->GetNdaughters())
1229 Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform",
1230 toTransform->GetName());
1231 if (toTransform->IsVolumeMulti())
1232 Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1233 }
1234 }
1235 index++;
1236 if (index >= indmax)
1237 return count;
1239 if (!strcmp(toTransform->GetName(), vname))
1240 replace = kTRUE;
1241 }
1242 return count;
1243}
1244
1245////////////////////////////////////////////////////////////////////////////////
1246/// Create a new volume by dividing an existing one (GEANT3 like)
1247///
1248/// Divides MOTHER into NDIV divisions called NAME
1249/// along axis IAXIS starting at coordinate value START
1250/// and having size STEP. The created volumes will have tracking
1251/// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1252/// The behavior of the division operation can be triggered using OPTION :
1253///
1254/// OPTION (case insensitive) :
1255/// - N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1256/// - NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1257/// - S - divide all range with given STEP. NDIV is computed and divisions will be centered
1258/// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1259/// - SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1260
1261TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start,
1263{
1264 return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1265}
1266
1267////////////////////////////////////////////////////////////////////////////////
1268/// Create rotation matrix named 'mat<index>'.
1269///
1270/// - index rotation matrix number
1271/// - theta1 polar angle for axis X
1272/// - phi1 azimuthal angle for axis X
1273/// - theta2 polar angle for axis Y
1274/// - phi2 azimuthal angle for axis Y
1275/// - theta3 polar angle for axis Z
1276/// - phi3 azimuthal angle for axis Z
1277///
1278
1284
1285////////////////////////////////////////////////////////////////////////////////
1286/// Create material with given A, Z and density, having an unique id.
1287
1290{
1291 return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1292}
1293
1294////////////////////////////////////////////////////////////////////////////////
1295/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1296/// materials defined by arrays A,Z and WMAT, having an unique id.
1297
1300{
1301 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1302}
1303
1304////////////////////////////////////////////////////////////////////////////////
1305/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1306/// materials defined by arrays A,Z and WMAT, having an unique id.
1307
1310{
1311 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1312}
1313
1314////////////////////////////////////////////////////////////////////////////////
1315/// Create tracking medium
1316///
1317/// - numed tracking medium number assigned
1318/// - name tracking medium name
1319/// - nmat material number
1320/// - isvol sensitive volume flag
1321/// - ifield magnetic field
1322/// - fieldm max. field value (kilogauss)
1323/// - tmaxfd max. angle due to field (deg/step)
1324/// - stemax max. step allowed
1325/// - deemax max. fraction of energy lost in a step
1326/// - epsil tracking precision (cm)
1327/// - stmin min. step due to continuous processes (cm)
1328///
1329/// - ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1330/// - ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1331/// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1332///
1333
1340
1341////////////////////////////////////////////////////////////////////////////////
1342/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1343/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1344/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1345/// In case npar>0, create the volume to be positioned in mother, according
1346/// its actual parameters (gsposp).
1347/// - NAME Volume name
1348/// - NUMBER Copy number of the volume
1349/// - MOTHER Mother volume name
1350/// - X X coord. of the volume in mother ref. sys.
1351/// - Y Y coord. of the volume in mother ref. sys.
1352/// - Z Z coord. of the volume in mother ref. sys.
1353/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1354/// - ISONLY ONLY/MANY flag
1355
1358{
1359 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1360}
1361
1362////////////////////////////////////////////////////////////////////////////////
1363/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1364/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1365/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1366/// In case npar>0, create the volume to be positioned in mother, according
1367/// its actual parameters (gsposp).
1368/// - NAME Volume name
1369/// - NUMBER Copy number of the volume
1370/// - MOTHER Mother volume name
1371/// - X X coord. of the volume in mother ref. sys.
1372/// - Y Y coord. of the volume in mother ref. sys.
1373/// - Z Z coord. of the volume in mother ref. sys.
1374/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1375/// - ISONLY ONLY/MANY flag
1376
1379{
1380 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1381}
1382
1383////////////////////////////////////////////////////////////////////////////////
1384/// Create a volume in GEANT3 style.
1385/// - NAME Volume name
1386/// - SHAPE Volume type
1387/// - NMED Tracking medium number
1388/// - NPAR Number of shape parameters
1389/// - UPAR Vector containing shape parameters
1390
1391TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar)
1392{
1393 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1394}
1395
1396////////////////////////////////////////////////////////////////////////////////
1397/// Create a volume in GEANT3 style.
1398/// - NAME Volume name
1399/// - SHAPE Volume type
1400/// - NMED Tracking medium number
1401/// - NPAR Number of shape parameters
1402/// - UPAR Vector containing shape parameters
1403
1405{
1406 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1407}
1408
1409////////////////////////////////////////////////////////////////////////////////
1410/// Assigns uid's for all materials,media and matrices.
1411
1413{
1414 Int_t index = 1;
1415 TIter next(fMaterials);
1417 while ((mater = (TGeoMaterial *)next())) {
1418 mater->SetUniqueID(index++);
1420 }
1421 index = 1;
1423 TGeoMedium *med;
1424 while ((med = (TGeoMedium *)next1())) {
1425 med->SetUniqueID(index++);
1427 }
1428 index = 1;
1430 TGeoShape *shape;
1431 while ((shape = (TGeoShape *)next2())) {
1432 shape->SetUniqueID(index++);
1433 if (shape->IsComposite())
1434 ((TGeoCompositeShape *)shape)->GetBoolNode()->RegisterMatrices();
1435 }
1436
1439 while ((matrix = (TGeoMatrix *)next3())) {
1440 matrix->RegisterYourself();
1441 }
1443 index = 1;
1444 while ((matrix = (TGeoMatrix *)next4())) {
1445 matrix->SetUniqueID(index++);
1447 }
1449 TGeoVolume *vol;
1450 while ((vol = (TGeoVolume *)next5()))
1451 vol->UnmarkSaved();
1452}
1453
1454////////////////////////////////////////////////////////////////////////////////
1455/// Reset all attributes to default ones. Default attributes for visualization
1456/// are those defined before closing the geometry.
1457
1459{
1460 if (gPad)
1461 delete gPad;
1462 gPad = nullptr;
1463 SetVisOption(0);
1464 SetVisLevel(3);
1465 SetExplodedView(0);
1467 if (!gStyle)
1468 return;
1469 TIter next(fVolumes);
1470 TGeoVolume *vol = nullptr;
1471 while ((vol = (TGeoVolume *)next())) {
1472 if (!vol->IsVisTouched())
1473 continue;
1474 vol->SetVisTouched(kFALSE);
1475 }
1476}
1477////////////////////////////////////////////////////////////////////////////////
1478/// Closing geometry implies checking the geometry validity, fixing shapes
1479/// with negative parameters (run-time shapes)building the cache manager,
1480/// voxelizing all volumes, counting the total number of physical nodes and
1481/// registering the manager class to the browser.
1482
1484{
1485 if (fClosed) {
1486 Warning("CloseGeometry", "geometry already closed");
1487 return;
1488 }
1489 if (!fMasterVolume) {
1490 Error("CloseGeometry", "you MUST call SetTopVolume() first !");
1491 return;
1492 }
1493 if (!gROOT->GetListOfGeometries()->FindObject(this))
1494 gROOT->GetListOfGeometries()->Add(this);
1495 if (!gROOT->GetListOfBrowsables()->FindObject(this))
1496 gROOT->GetListOfBrowsables()->Add(this);
1497 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1498 // TIter next(brlist);
1499 // TBrowser *browser = 0;
1500 // while ((browser=(TBrowser*)next())) browser->Refresh();
1501 TString opt(option);
1502 opt.ToLower();
1503 // Bool_t dummy = opt.Contains("d");
1504 Bool_t nodeid = opt.Contains("i");
1505 // Create a geometry navigator if not present
1506 TGeoNavigator *nav = nullptr;
1507 Int_t nnavigators = 0;
1508 // Check if the geometry is streamed from file
1509 if (fIsGeomReading) {
1510 if (fgVerboseLevel > 0)
1511 Info("CloseGeometry", "Geometry loaded from file...");
1513 if (!fElementTable)
1515 if (!fTopNode) {
1516 if (!fMasterVolume) {
1517 Error("CloseGeometry", "Master volume not streamed");
1518 return;
1519 }
1521 if (fStreamVoxels && fgVerboseLevel > 0)
1522 Info("CloseGeometry", "Voxelization retrieved from file");
1523 }
1524 // Create a geometry navigator if not present
1525 if (!GetCurrentNavigator())
1528 if (!opt.Contains("nv")) {
1529 Voxelize("ALL");
1530 }
1531 CountLevels();
1532 for (Int_t i = 0; i < nnavigators; i++) {
1534 nav->GetCache()->BuildInfoBranch();
1535 if (nodeid)
1536 nav->GetCache()->BuildIdArray();
1537 }
1538 if (!fHashVolumes) {
1541 fHashVolumes = new THashList(nvol + 1);
1542 fHashGVolumes = new THashList(ngvol + 1);
1543 Int_t i;
1544 for (i = 0; i < ngvol; i++)
1546 for (i = 0; i < nvol; i++)
1548 }
1549 fClosed = kTRUE;
1550 if (fParallelWorld) {
1551 if (fgVerboseLevel > 0)
1552 Info("CloseGeometry", "Recreating parallel world %s ...", fParallelWorld->GetName());
1554 }
1555
1556 if (fgVerboseLevel > 0)
1557 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1558 GetTitle());
1559 if (fgVerboseLevel > 0)
1560 Info("CloseGeometry", "----------------modeler ready----------------");
1561 return;
1562 }
1563
1564 // Create a geometry navigator if not present
1565 if (!GetCurrentNavigator())
1569 CheckGeometry();
1570 if (fgVerboseLevel > 0)
1571 Info("CloseGeometry", "Counting nodes...");
1572 fNNodes = CountNodes();
1573 fNLevel = fMasterVolume->CountNodes(1, 3) + 1;
1574 if (fNLevel < 30)
1575 fNLevel = 100;
1576
1577 // BuildIdArray();
1578 // avoid voxelization if requested to speed up geometry startup
1579 if (!opt.Contains("nv")) {
1580 Voxelize("ALL");
1581 } else {
1582 TGeoVolume *vol;
1583 TIter next(fVolumes);
1584 while ((vol = (TGeoVolume *)next())) {
1585 vol->SortNodes();
1586 }
1587 }
1588 if (fgVerboseLevel > 0)
1589 Info("CloseGeometry", "Building cache...");
1590 CountLevels();
1591 for (Int_t i = 0; i < nnavigators; i++) {
1593 nav->GetCache()->BuildInfoBranch();
1594 if (nodeid)
1595 nav->GetCache()->BuildIdArray();
1596 }
1597 fClosed = kTRUE;
1598 if (fgVerboseLevel > 0) {
1599 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1600 GetTitle());
1601 Info("CloseGeometry", "----------------modeler ready----------------");
1602 }
1603}
1604
1605////////////////////////////////////////////////////////////////////////////////
1606/// Clear the list of overlaps.
1607
1609{
1610 if (fOverlaps) {
1611 fOverlaps->Delete();
1612 delete fOverlaps;
1613 }
1614 fOverlaps = new TObjArray();
1615}
1616
1617////////////////////////////////////////////////////////////////////////////////
1618/// Remove a shape from the list of shapes.
1619
1621{
1622 if (fShapes->FindObject(shape))
1623 fShapes->Remove((TGeoShape *)shape);
1624 delete shape;
1625}
1626
1627////////////////////////////////////////////////////////////////////////////////
1628/// Clean temporary volumes and shapes from garbage collection.
1629
1631{
1632 if (!fGVolumes && !fGShapes)
1633 return;
1634 Int_t i, nentries;
1635 if (fGVolumes) {
1637 TGeoVolume *vol = nullptr;
1638 for (i = 0; i < nentries; i++) {
1639 vol = (TGeoVolume *)fGVolumes->At(i);
1640 if (vol)
1641 vol->SetFinder(nullptr);
1642 }
1643 fGVolumes->Delete();
1644 delete fGVolumes;
1645 fGVolumes = nullptr;
1646 }
1647 if (fGShapes) {
1648 fGShapes->Delete();
1649 delete fGShapes;
1650 fGShapes = nullptr;
1651 }
1652}
1653
1654////////////////////////////////////////////////////////////////////////////////
1655/// Change current path to point to the node having this id.
1656/// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1657
1659{
1660 GetCurrentNavigator()->CdNode(nodeid);
1661}
1662
1663////////////////////////////////////////////////////////////////////////////////
1664/// Get the unique ID of the current node.
1665
1670
1671////////////////////////////////////////////////////////////////////////////////
1672/// Make top level node the current node. Updates the cache accordingly.
1673/// Determine the overlapping state of current node.
1674
1676{
1678}
1679
1680////////////////////////////////////////////////////////////////////////////////
1681/// Go one level up in geometry. Updates cache accordingly.
1682/// Determine the overlapping state of current node.
1683
1685{
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Make a daughter of current node current. Can be called only with a valid
1691/// daughter index (no check). Updates cache accordingly.
1692
1697
1698////////////////////////////////////////////////////////////////////////////////
1699/// Do a cd to the node found next by FindNextBoundary
1700
1702{
1704}
1705
1706////////////////////////////////////////////////////////////////////////////////
1707/// Browse the tree of nodes starting from fTopNode according to pathname.
1708/// Changes the path accordingly.
1709
1710Bool_t TGeoManager::cd(const char *path)
1711{
1712 return GetCurrentNavigator()->cd(path);
1713}
1714
1715////////////////////////////////////////////////////////////////////////////////
1716/// Check if a geometry path is valid without changing the state of the current navigator.
1717
1718Bool_t TGeoManager::CheckPath(const char *path) const
1719{
1720 return GetCurrentNavigator()->CheckPath(path);
1721}
1722
1723////////////////////////////////////////////////////////////////////////////////
1724/// Convert all reflections in geometry to normal rotations + reflected shapes.
1725
1727{
1728 if (!fTopNode)
1729 return;
1730 if (fgVerboseLevel > 0)
1731 Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1733 TGeoNode *node;
1737 while ((node = next())) {
1738 matrix = node->GetMatrix();
1739 if (matrix->IsReflection()) {
1740 // printf("%s before\n", node->GetName());
1741 // matrix->Print();
1743 mclone->RegisterYourself();
1744 // Reflect just the rotation component
1745 mclone->ReflectZ(kFALSE, kTRUE);
1746 nodematrix = (TGeoNodeMatrix *)node;
1747 nodematrix->SetMatrix(mclone);
1748 // printf("%s after\n", node->GetName());
1749 // node->GetMatrix()->Print();
1751 node->SetVolume(reflected);
1752 }
1753 }
1754 if (fgVerboseLevel > 0)
1755 Info("ConvertReflections", "Done");
1756}
1757
1758////////////////////////////////////////////////////////////////////////////////
1759/// Count maximum number of nodes per volume, maximum depth and maximum
1760/// number of xtru vertices.
1761
1763{
1764 if (!fTopNode) {
1765 Error("CountLevels", "Top node not defined.");
1766 return;
1767 }
1770 if (fMasterVolume->GetRefCount() > 1)
1772 if (fgVerboseLevel > 1 && fixrefs)
1773 Info("CountLevels", "Fixing volume reference counts");
1774 TGeoNode *node;
1775 Int_t maxlevel = 1;
1777 Int_t maxvertices = 1;
1778 while ((node = next())) {
1779 if (fixrefs) {
1780 node->GetVolume()->Grab();
1781 for (Int_t ibit = 10; ibit < 14; ibit++) {
1782 node->SetBit(BIT(ibit + 4), node->TestBit(BIT(ibit)));
1783 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1784 }
1785 }
1786 if (node->GetNdaughters() > maxnodes)
1787 maxnodes = node->GetNdaughters();
1788 if (next.GetLevel() > maxlevel)
1789 maxlevel = next.GetLevel();
1790 if (node->GetVolume()->GetShape()->IsA() == TGeoXtru::Class()) {
1791 TGeoXtru *xtru = (TGeoXtru *)node->GetVolume()->GetShape();
1792 if (xtru->GetNvert() > maxvertices)
1793 maxvertices = xtru->GetNvert();
1794 }
1795 }
1799 if (fgVerboseLevel > 0)
1800 Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1801}
1802
1803////////////////////////////////////////////////////////////////////////////////
1804/// Count the total number of nodes starting from a volume, nlevels down.
1805
1807{
1808 TGeoVolume *top;
1809 if (!vol) {
1810 top = fTopVolume;
1811 } else {
1812 top = (TGeoVolume *)vol;
1813 }
1814 Int_t count = top->CountNodes(nlevels, option);
1815 return count;
1816}
1817
1818////////////////////////////////////////////////////////////////////////////////
1819/// Set default angles for a given view.
1820
1822{
1823 if (fPainter)
1825}
1826
1827////////////////////////////////////////////////////////////////////////////////
1828/// Draw current point in the same view.
1829
1831{
1832 if (fPainter)
1833 fPainter->DrawCurrentPoint(color);
1834}
1835
1836////////////////////////////////////////////////////////////////////////////////
1837/// Draw animation of tracks
1838
1840{
1843 if (tmin < 0 || tmin >= tmax || nframes < 1)
1844 return;
1846 box[0] = box[1] = box[2] = 0;
1847 box[3] = box[4] = box[5] = 100;
1848 Double_t dt = (tmax - tmin) / Double_t(nframes);
1849 Double_t delt = 2E-9;
1850 Double_t t = tmin;
1851 Int_t i, j;
1852 TString opt(option);
1853 Bool_t save = kFALSE, geomanim = kFALSE;
1854 TString fname;
1855 if (opt.Contains("/S"))
1856 save = kTRUE;
1857
1858 if (opt.Contains("/G"))
1859 geomanim = kTRUE;
1860 SetTminTmax(0, 0);
1861 DrawTracks(opt.Data());
1862 Double_t start[6] = {0, 0, 0, 0, 0, 0};
1863 Double_t end[6] = {0, 0, 0, 0, 0, 0};
1864 Double_t dd[6] = {0, 0, 0, 0, 0, 0};
1865 Double_t dlat = 0, dlong = 0, dpsi = 0;
1866 if (geomanim) {
1867 fPainter->EstimateCameraMove(tmin + 5 * dt, tmin + 15 * dt, start, end);
1868 for (i = 0; i < 3; i++) {
1869 start[i + 3] = 20 + 1.3 * start[i + 3];
1870 end[i + 3] = 20 + 0.9 * end[i + 3];
1871 }
1872 for (i = 0; i < 6; i++) {
1873 dd[i] = (end[i] - start[i]) / 10.;
1874 }
1875 memcpy(box, start, 6 * sizeof(Double_t));
1877 dlong = (-206 - dlong) / Double_t(nframes);
1878 dlat = (126 - dlat) / Double_t(nframes);
1879 dpsi = (75 - dpsi) / Double_t(nframes);
1881 }
1882
1883 for (i = 0; i < nframes; i++) {
1884 if (t - delt < 0)
1885 SetTminTmax(t - delt, t);
1886 else
1887 gGeoManager->SetTminTmax(t - delt, t);
1888 if (geomanim) {
1889 for (j = 0; j < 6; j++)
1890 box[j] += dd[j];
1892 } else {
1893 ModifiedPad();
1894 }
1895 if (save) {
1896 fname = TString::Format("anim%04d.gif", i);
1897 gPad->Print(fname);
1898 }
1899 t += dt;
1900 }
1902}
1903
1904////////////////////////////////////////////////////////////////////////////////
1905/// Draw tracks over the geometry, according to option. By default, only
1906/// primaries are drawn. See TGeoTrack::Draw() for additional options.
1907
1909{
1911 // SetVisLevel(1);
1912 // SetVisOption(1);
1914 for (Int_t i = 0; i < fNtracks; i++) {
1915 track = GetTrack(i);
1916 if (track)
1917 track->Draw(option);
1918 }
1920 ModifiedPad();
1921}
1922
1923////////////////////////////////////////////////////////////////////////////////
1924/// Draw current path
1925
1926void TGeoManager::DrawPath(const char *path, Option_t *option)
1927{
1928 if (!fTopVolume)
1929 return;
1931 GetGeomPainter()->DrawPath(path, option);
1932}
1933
1934////////////////////////////////////////////////////////////////////////////////
1935/// Draw random points in the bounding box of a volume.
1936
1941
1942////////////////////////////////////////////////////////////////////////////////
1943/// Check time of finding "Where am I" for n points.
1944
1949
1950////////////////////////////////////////////////////////////////////////////////
1951/// Geometry overlap checker based on sampling.
1952
1953void TGeoManager::TestOverlaps(const char *path)
1954{
1956}
1957
1958////////////////////////////////////////////////////////////////////////////////
1959/// Fill volume names of current branch into an array.
1960
1962{
1964}
1965
1966////////////////////////////////////////////////////////////////////////////////
1967/// Get name for given pdg code;
1968
1970{
1971 static char defaultname[5] = {"XXX"};
1972 if (!fPdgNames || !pdg)
1973 return defaultname;
1974 for (Int_t i = 0; i < fNpdg; i++) {
1975 if (fPdgId[i] == pdg)
1976 return fPdgNames->At(i)->GetName();
1977 }
1978 return defaultname;
1979}
1980
1981////////////////////////////////////////////////////////////////////////////////
1982/// Set a name for a particle having a given pdg.
1983
1985{
1986 if (!pdg)
1987 return;
1988 if (!fPdgNames) {
1989 fPdgNames = new TObjArray(1024);
1990 }
1991 if (!strcmp(name, GetPdgName(pdg)))
1992 return;
1993 // store pdg name
1994 if (fNpdg > 1023) {
1995 Warning("SetPdgName", "No more than 256 different pdg codes allowed");
1996 return;
1997 }
1998 fPdgId[fNpdg] = pdg;
1999 TNamed *pdgname = new TNamed(name, "");
2001}
2002
2003////////////////////////////////////////////////////////////////////////////////
2004/// Get GDML matrix with a given name;
2005
2007{
2009}
2010
2011////////////////////////////////////////////////////////////////////////////////
2012/// Add GDML matrix;
2014{
2015 if (GetGDMLMatrix(mat->GetName())) {
2016 Error("AddGDMLMatrix", "Matrix %s already added to manager", mat->GetName());
2017 return;
2018 }
2020}
2021
2022////////////////////////////////////////////////////////////////////////////////
2023/// Get optical surface with a given name;
2024
2029
2030////////////////////////////////////////////////////////////////////////////////
2031/// Add optical surface;
2033{
2034 if (GetOpticalSurface(optsurf->GetName())) {
2035 Error("AddOpticalSurface", "Surface %s already added to manager", optsurf->GetName());
2036 return;
2037 }
2039}
2040
2041////////////////////////////////////////////////////////////////////////////////
2042/// Get skin surface with a given name;
2043
2048
2049////////////////////////////////////////////////////////////////////////////////
2050/// Add skin surface;
2052{
2053 if (GetSkinSurface(surf->GetName())) {
2054 Error("AddSkinSurface", "Surface %s already added to manager", surf->GetName());
2055 return;
2056 }
2058}
2059
2060////////////////////////////////////////////////////////////////////////////////
2061/// Get border surface with a given name;
2062
2067
2068////////////////////////////////////////////////////////////////////////////////
2069/// Add border surface;
2071{
2072 if (GetBorderSurface(surf->GetName())) {
2073 Error("AddBorderSurface", "Surface %s already added to manager", surf->GetName());
2074 return;
2075 }
2077}
2078
2079////////////////////////////////////////////////////////////////////////////////
2080/// Fill node copy numbers of current branch into an array.
2081
2086
2087////////////////////////////////////////////////////////////////////////////////
2088/// Fill node copy numbers of current branch into an array.
2089
2094
2095////////////////////////////////////////////////////////////////////////////////
2096/// Retrieve cartesian and radial bomb factors.
2097
2099{
2100 if (fPainter) {
2102 return;
2103 }
2104 bombx = bomby = bombz = bombr = 1.3;
2105}
2106
2107////////////////////////////////////////////////////////////////////////////////
2108/// Return maximum number of daughters of a volume used in the geometry.
2109
2114
2115////////////////////////////////////////////////////////////////////////////////
2116/// Return maximum number of levels used in the geometry.
2117
2119{
2120 return fgMaxLevel;
2121}
2122
2123////////////////////////////////////////////////////////////////////////////////
2124/// Return maximum number of vertices for an xtru shape used.
2125
2130
2131////////////////////////////////////////////////////////////////////////////////
2132/// Returns number of threads that were set to use geometry.
2133
2138
2139////////////////////////////////////////////////////////////////////////////////
2140/// Return stored current matrix (global matrix of the next touched node).
2141
2143{
2144 if (!GetCurrentNavigator())
2145 return nullptr;
2146 return GetCurrentNavigator()->GetHMatrix();
2147}
2148
2149////////////////////////////////////////////////////////////////////////////////
2150/// Returns current depth to which geometry is drawn.
2151
2153{
2154 return fVisLevel;
2155}
2156
2157////////////////////////////////////////////////////////////////////////////////
2158/// Returns current depth to which geometry is drawn.
2159
2161{
2162 return fVisOption;
2163}
2164
2165////////////////////////////////////////////////////////////////////////////////
2166/// Find level of virtuality of current overlapping node (number of levels
2167/// up having the same tracking media.
2168
2173
2174////////////////////////////////////////////////////////////////////////////////
2175/// Search the track hierarchy to find the track with the
2176/// given id
2177///
2178/// if 'primsFirst' is true, then:
2179/// first tries TGeoManager::GetTrackOfId, then does a
2180/// recursive search if that fails. this would be faster
2181/// if the track is somehow known to be a primary
2182
2184{
2185 TVirtualGeoTrack *trk = nullptr;
2186 trk = GetTrackOfId(id);
2187 if (trk)
2188 return trk;
2189 // need recursive search
2190 TIter next(fTracks);
2192 while ((prim = (TVirtualGeoTrack *)next())) {
2193 trk = prim->FindTrackWithId(id);
2194 if (trk)
2195 return trk;
2196 }
2197 return nullptr;
2198}
2199
2200////////////////////////////////////////////////////////////////////////////////
2201/// Get track with a given ID.
2202
2204{
2206 for (Int_t i = 0; i < fNtracks; i++) {
2207 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2208 if (track->GetId() == id)
2209 return track;
2210 }
2211 }
2212 return nullptr;
2213}
2214
2215////////////////////////////////////////////////////////////////////////////////
2216/// Get parent track with a given ID.
2217
2219{
2221 while ((track = track->GetMother())) {
2222 if (track->GetId() == id)
2223 return track;
2224 }
2225 return nullptr;
2226}
2227
2228////////////////////////////////////////////////////////////////////////////////
2229/// Get index for track id, -1 if not found.
2230
2232{
2234 for (Int_t i = 0; i < fNtracks; i++) {
2235 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2236 if (track->GetId() == id)
2237 return i;
2238 }
2239 }
2240 return -1;
2241}
2242
2243////////////////////////////////////////////////////////////////////////////////
2244/// Go upwards the tree until a non-overlapping node
2245
2250
2251////////////////////////////////////////////////////////////////////////////////
2252/// Go upwards the tree until a non-overlapping node
2253
2258
2259////////////////////////////////////////////////////////////////////////////////
2260/// Set default volume colors according to A of material
2261
2263{
2264 const Int_t nmax = 110;
2265 Int_t col[nmax];
2266 for (Int_t i = 0; i < nmax; i++)
2267 col[i] = kGray;
2268
2269 // here we should create a new TColor with the same rgb as in the default
2270 // ROOT colors used below
2271 col[3] = kYellow - 10;
2272 col[4] = col[5] = kGreen - 10;
2273 col[6] = col[7] = kBlue - 7;
2274 col[8] = col[9] = kMagenta - 3;
2275 col[10] = col[11] = kRed - 10;
2276 col[12] = kGray + 1;
2277 col[13] = kBlue - 10;
2278 col[14] = kOrange + 7;
2279 col[16] = kYellow + 1;
2280 col[20] = kYellow - 10;
2281 col[24] = col[25] = col[26] = kBlue - 8;
2282 col[29] = kOrange + 9;
2283 col[79] = kOrange - 2;
2284
2285 TGeoVolume *vol;
2286 TIter next(fVolumes);
2287 while ((vol = (TGeoVolume *)next())) {
2288 TGeoMedium *med = vol->GetMedium();
2289 if (!med)
2290 continue;
2291 TGeoMaterial *mat = med->GetMaterial();
2292 Int_t matZ = (Int_t)mat->GetZ();
2293 vol->SetLineColor(col[matZ]);
2294 if (mat->GetDensity() < 0.1)
2295 vol->SetTransparency(60);
2296 }
2297}
2298
2299////////////////////////////////////////////////////////////////////////////////
2300/// Compute safe distance from the current point. This represent the distance
2301/// from POINT to the closest boundary.
2302
2304{
2305 return GetCurrentNavigator()->Safety(inside);
2306}
2307
2308////////////////////////////////////////////////////////////////////////////////
2309/// Set volume attributes in G3 style.
2310
2311void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2312{
2313 TGeoVolume *volume;
2314 Bool_t all = kFALSE;
2315 if (strstr(name, "*"))
2316 all = kTRUE;
2317 Int_t ivo = 0;
2318 TIter next(fVolumes);
2319 TString chatt = att;
2320 chatt.ToLower();
2321 while ((volume = (TGeoVolume *)next())) {
2322 if (strcmp(volume->GetName(), name) && !all)
2323 continue;
2324 ivo++;
2325 if (chatt.Contains("colo"))
2326 volume->SetLineColor(val);
2327 if (chatt.Contains("lsty"))
2328 volume->SetLineStyle(val);
2329 if (chatt.Contains("lwid"))
2330 volume->SetLineWidth(val);
2331 if (chatt.Contains("fill"))
2332 volume->SetFillColor(val);
2333 if (chatt.Contains("seen"))
2334 volume->SetVisibility(val);
2335 }
2337 while ((volume = (TGeoVolume *)next1())) {
2338 if (strcmp(volume->GetName(), name) && !all)
2339 continue;
2340 ivo++;
2341 if (chatt.Contains("colo"))
2342 volume->SetLineColor(val);
2343 if (chatt.Contains("lsty"))
2344 volume->SetLineStyle(val);
2345 if (chatt.Contains("lwid"))
2346 volume->SetLineWidth(val);
2347 if (chatt.Contains("fill"))
2348 volume->SetFillColor(val);
2349 if (chatt.Contains("seen"))
2350 volume->SetVisibility(val);
2351 }
2352 if (!ivo) {
2353 Warning("SetVolumeAttribute", "volume: %s does not exist", name);
2354 }
2355}
2356
2357////////////////////////////////////////////////////////////////////////////////
2358/// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2359
2365
2366////////////////////////////////////////////////////////////////////////////////
2367/// Set a user-defined shape as clipping for ray tracing.
2368
2370{
2372 if (shape) {
2373 if (fClippingShape && (fClippingShape != shape))
2375 fClippingShape = shape;
2376 }
2377 painter->SetClippingShape(shape);
2378}
2379
2380////////////////////////////////////////////////////////////////////////////////
2381/// set the maximum number of visible nodes.
2382
2384{
2386 if (maxnodes > 0 && fgVerboseLevel > 0)
2387 Info("SetMaxVisNodes", "Automatic visible depth for %d visible nodes", maxnodes);
2388 if (!fPainter)
2389 return;
2391 Int_t level = fPainter->GetVisLevel();
2392 if (level != fVisLevel)
2393 fVisLevel = level;
2394}
2395
2396////////////////////////////////////////////////////////////////////////////////
2397/// make top volume visible on screen
2398
2404
2405////////////////////////////////////////////////////////////////////////////////
2406/// Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
2407
2412
2413////////////////////////////////////////////////////////////////////////////////
2414/// Set the number of points to be generated on the shape outline when checking
2415/// for overlaps.
2416
2421
2422////////////////////////////////////////////////////////////////////////////////
2423/// set drawing mode :
2424/// - option=0 (default) all nodes drawn down to vislevel
2425/// - option=1 leaves and nodes at vislevel drawn
2426/// - option=2 path is drawn
2427/// - option=4 visibility changed
2428
2430{
2431 if ((option >= 0) && (option < 3))
2433 if (fPainter)
2435}
2436
2437////////////////////////////////////////////////////////////////////////////////
2438/// Set visualization option (leaves only OR all volumes)
2439
2441{
2442 if (flag)
2443 SetVisOption(1);
2444 else
2445 SetVisOption(0);
2446}
2447
2448////////////////////////////////////////////////////////////////////////////////
2449/// Set density threshold. Volumes with densities lower than this become
2450/// transparent.
2451
2458
2459////////////////////////////////////////////////////////////////////////////////
2460/// set default level down to which visualization is performed
2461
2463{
2464 if (level > 0) {
2465 fVisLevel = level;
2466 fMaxVisNodes = 0;
2467 if (fgVerboseLevel > 0)
2468 Info("SetVisLevel", "Automatic visible depth disabled");
2469 if (fPainter)
2471 } else {
2473 }
2474}
2475
2476////////////////////////////////////////////////////////////////////////////////
2477/// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2478
2480{
2481 fOverlaps->Sort();
2482}
2483
2484////////////////////////////////////////////////////////////////////////////////
2485/// Optimize voxelization type for all volumes. Save best choice in a macro.
2486
2488{
2489 if (!fTopNode) {
2490 Error("OptimizeVoxels", "Geometry must be closed first");
2491 return;
2492 }
2493 std::ofstream out;
2495 if (fname.IsNull())
2496 fname = "tgeovox.C";
2497 out.open(fname, std::ios::out);
2498 if (!out.good()) {
2499 Error("OptimizeVoxels", "cannot open file");
2500 return;
2501 }
2502 // write header
2503 TDatime t;
2505 sname.ReplaceAll(".C", "");
2506 out << sname.Data() << "()" << std::endl;
2507 out << "{" << std::endl;
2508 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2509 out << "//=== Voxel optimization for " << GetTitle() << " geometry" << std::endl;
2510 out << "//===== <run this macro JUST BEFORE closing the geometry>" << std::endl;
2511 out << " TGeoVolume *vol = 0;" << std::endl;
2512 out << " // parse all voxelized volumes" << std::endl;
2513 TGeoVolume *vol = nullptr;
2515 TIter next(fVolumes);
2516 while ((vol = (TGeoVolume *)next())) {
2517 if (!vol->GetVoxels())
2518 continue;
2519 out << " vol = gGeoManager->GetVolume(\"" << vol->GetName() << "\");" << std::endl;
2520 cyltype = vol->OptimizeVoxels();
2521 if (cyltype) {
2522 out << " vol->SetCylVoxels();" << std::endl;
2523 } else {
2524 out << " vol->SetCylVoxels(kFALSE);" << std::endl;
2525 }
2526 }
2527 out << "}" << std::endl;
2528 out.close();
2529}
2530////////////////////////////////////////////////////////////////////////////////
2531/// Parse a string boolean expression and do a syntax check. Find top
2532/// level boolean operator and returns its type. Fill the two
2533/// substrings to which this operator applies. The returned integer is :
2534/// - -1 : parse error
2535/// - 0 : no boolean operator
2536/// - 1 : union - represented as '+' in expression
2537/// - 2 : difference (subtraction) - represented as '-' in expression
2538/// - 3 : intersection - represented as '*' in expression.
2539/// Parentheses should be used to avoid ambiguities. For instance :
2540/// - A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2541/// eliminate not needed parentheses
2542
2544{
2546 Int_t len = startstr.Length();
2547 Int_t i;
2548 TString e0 = "";
2549 expr3 = "";
2550 // eliminate blanks
2551 for (i = 0; i < len; i++) {
2552 if (startstr(i) == ' ')
2553 continue;
2554 e0 += startstr(i, 1);
2555 }
2556 Int_t level = 0;
2557 Int_t levmin = 999;
2558 Int_t boolop = 0;
2559 Int_t indop = 0;
2560 Int_t iloop = 1;
2561 Int_t lastop = 0;
2562 Int_t lastdp = 0;
2563 Int_t lastpp = 0;
2565 // check/eliminate parentheses
2566 while (iloop == 1) {
2567 iloop = 0;
2568 lastop = 0;
2569 lastdp = 0;
2570 lastpp = 0;
2571 len = e0.Length();
2572 for (i = 0; i < len; i++) {
2573 if (e0(i) == '(') {
2574 if (!level)
2575 iloop++;
2576 level++;
2577 continue;
2578 }
2579 if (e0(i) == ')') {
2580 level--;
2581 if (level == 0)
2582 lastpp = i;
2583 continue;
2584 }
2585 if ((e0(i) == '+') || (e0(i) == '-') || (e0(i) == '*')) {
2586 lastop = i;
2587 if (level < levmin) {
2588 levmin = level;
2589 indop = i;
2590 }
2591 continue;
2592 }
2593 if ((e0(i) == ':') && (level == 0)) {
2594 lastdp = i;
2595 continue;
2596 }
2597 }
2598 if (level != 0) {
2599 if (gGeoManager)
2600 gGeoManager->Error("Parse", "parentheses does not match");
2601 return -1;
2602 }
2603 if (iloop == 1 && (e0(0) == '(') && (e0(len - 1) == ')')) {
2604 // eliminate extra parentheses
2605 e0 = e0(1, len - 2);
2606 continue;
2607 }
2608 if (foundmat)
2609 break;
2610 if (((lastop == 0) && (lastdp > 0)) || ((lastpp > 0) && (lastdp > lastpp) && (indop < lastpp))) {
2611 expr3 = e0(lastdp + 1, len - lastdp);
2612 e0 = e0(0, lastdp);
2613 foundmat = kTRUE;
2614 iloop = 1;
2615 continue;
2616 } else
2617 break;
2618 }
2619 // loop expression and search parentheses/operators
2620 levmin = 999;
2621 for (i = 0; i < len; i++) {
2622 if (e0(i) == '(') {
2623 level++;
2624 continue;
2625 }
2626 if (e0(i) == ')') {
2627 level--;
2628 continue;
2629 }
2630 // Take LAST operator at lowest level (revision 28/07/08)
2631 if (level <= levmin) {
2632 if (e0(i) == '+') {
2633 boolop = 1; // union
2634 levmin = level;
2635 indop = i;
2636 }
2637 if (e0(i) == '-') {
2638 boolop = 2; // difference
2639 levmin = level;
2640 indop = i;
2641 }
2642 if (e0(i) == '*') {
2643 boolop = 3; // intersection
2644 levmin = level;
2645 indop = i;
2646 }
2647 }
2648 }
2649 if (indop == 0) {
2650 expr1 = e0;
2651 return indop;
2652 }
2653 expr1 = e0(0, indop);
2654 expr2 = e0(indop + 1, len - indop);
2655 return boolop;
2656}
2657
2658////////////////////////////////////////////////////////////////////////////////
2659/// Save current attributes in a macro
2660
2662{
2663 if (!fTopNode) {
2664 Error("SaveAttributes", "geometry must be closed first\n");
2665 return;
2666 }
2667 std::ofstream out;
2669 if (fname.IsNull())
2670 fname = "tgeoatt.C";
2671 out.open(fname, std::ios::out);
2672 if (!out.good()) {
2673 Error("SaveAttributes", "cannot open file");
2674 return;
2675 }
2676 // write header
2677 TDatime t;
2679 sname.ReplaceAll(".C", "");
2680 out << sname.Data() << "()" << std::endl;
2681 out << "{" << std::endl;
2682 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2683 out << "//=== Attributes for " << GetTitle() << " geometry" << std::endl;
2684 out << "//===== <run this macro AFTER loading the geometry in memory>" << std::endl;
2685 // save current top volume
2686 out << " TGeoVolume *top = gGeoManager->GetVolume(\"" << fTopVolume->GetName() << "\");" << std::endl;
2687 out << " TGeoVolume *vol = 0;" << std::endl;
2688 out << " TGeoNode *node = 0;" << std::endl;
2689 out << " // clear all volume attributes and get painter" << std::endl;
2690 out << " gGeoManager->ClearAttributes();" << std::endl;
2691 out << " gGeoManager->GetGeomPainter();" << std::endl;
2692 out << " // set visualization modes and bomb factors" << std::endl;
2693 out << " gGeoManager->SetVisOption(" << GetVisOption() << ");" << std::endl;
2694 out << " gGeoManager->SetVisLevel(" << GetVisLevel() << ");" << std::endl;
2695 out << " gGeoManager->SetExplodedView(" << GetBombMode() << ");" << std::endl;
2698 out << " gGeoManager->SetBombFactors(" << bombx << "," << bomby << "," << bombz << "," << bombr << ");"
2699 << std::endl;
2700 out << " // iterate volumes container and set new attributes" << std::endl;
2701 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2702 TGeoVolume *vol = nullptr;
2704
2705 TIter next(fVolumes);
2706 while ((vol = (TGeoVolume *)next())) {
2707 vol->SetVisStreamed(kFALSE);
2708 }
2709 out << " // draw top volume with new settings" << std::endl;
2710 out << " top->Draw();" << std::endl;
2711 out << " gPad->x3d();" << std::endl;
2712 out << "}" << std::endl;
2713 out.close();
2714}
2715
2716////////////////////////////////////////////////////////////////////////////////
2717/// Returns the deepest node containing fPoint, which must be set a priori.
2718
2723
2724////////////////////////////////////////////////////////////////////////////////
2725/// Cross next boundary and locate within current node
2726/// The current point must be on the boundary of fCurrentNode.
2727
2732
2733////////////////////////////////////////////////////////////////////////////////
2734/// Compute distance to next boundary within STEPMAX. If no boundary is found,
2735/// propagate current point along current direction with fStep=STEPMAX. Otherwise
2736/// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2737/// node.
2738
2743
2744////////////////////////////////////////////////////////////////////////////////
2745/// Find distance to next boundary and store it in fStep. Returns node to which this
2746/// boundary belongs. If PATH is specified, compute only distance to the node to which
2747/// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2748/// than this value. STEPMAX represent the step to be made imposed by other reasons than
2749/// geometry (usually physics processes). Therefore in this case this method provides the
2750/// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2751/// fStep with a big number.
2752/// In case frombdr=kTRUE, the isotropic safety is set to zero.
2753///
2754/// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2755/// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2756/// they want this computed for the current point.
2757
2759{
2760 // convert current point and direction to local reference
2762}
2763
2764////////////////////////////////////////////////////////////////////////////////
2765/// Computes as fStep the distance to next daughter of the current volume.
2766/// The point and direction must be converted in the coordinate system of the current volume.
2767/// The proposed step limit is fStep.
2768
2773
2774////////////////////////////////////////////////////////////////////////////////
2775/// Reset current state flags.
2776
2781
2782////////////////////////////////////////////////////////////////////////////////
2783/// Returns deepest node containing current point.
2784
2789
2790////////////////////////////////////////////////////////////////////////////////
2791/// Returns deepest node containing current point.
2792
2797
2798////////////////////////////////////////////////////////////////////////////////
2799/// Computes fast normal to next crossed boundary, assuming that the current point
2800/// is close enough to the boundary. Works only after calling FindNextBoundary.
2801
2806
2807////////////////////////////////////////////////////////////////////////////////
2808/// Computes normal vector to the next surface that will be or was already
2809/// crossed when propagating on a straight line from a given point/direction.
2810/// Returns the normal vector cosines in the MASTER coordinate system. The dot
2811/// product of the normal and the current direction is positive defined.
2812
2814{
2815 return GetCurrentNavigator()->FindNormal(forward);
2816}
2817
2818////////////////////////////////////////////////////////////////////////////////
2819/// Checks if point (x,y,z) is still in the current node.
2820
2825
2826////////////////////////////////////////////////////////////////////////////////
2827/// Check if a new point with given coordinates is the same as the last located one.
2828
2833
2834////////////////////////////////////////////////////////////////////////////////
2835/// True if current node is in phi range
2836
2838{
2839 if (!fPhiCut)
2840 return kTRUE;
2841 const Double_t *origin;
2843 return kFALSE;
2844 origin = ((TGeoBBox *)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2845 Double_t point[3];
2846 LocalToMaster(origin, &point[0]);
2847 Double_t phi = TMath::ATan2(point[1], point[0]) * TMath::RadToDeg();
2848 if (phi < 0)
2849 phi += 360.;
2850 if ((phi >= fPhimin) && (phi <= fPhimax))
2851 return kFALSE;
2852 return kTRUE;
2853}
2854
2855////////////////////////////////////////////////////////////////////////////////
2856/// Initialize current point and current direction vector (normalized)
2857/// in MARS. Return corresponding node.
2858
2860{
2861 return GetCurrentNavigator()->InitTrack(point, dir);
2862}
2863
2864////////////////////////////////////////////////////////////////////////////////
2865/// Initialize current point and current direction vector (normalized)
2866/// in MARS. Return corresponding node.
2867
2872
2873////////////////////////////////////////////////////////////////////////////////
2874/// Inspects path and all flags for the current state.
2875
2880
2881////////////////////////////////////////////////////////////////////////////////
2882/// Get path to the current node in the form /node0/node1/...
2883
2884const char *TGeoManager::GetPath() const
2885{
2886 return GetCurrentNavigator()->GetPath();
2887}
2888
2889////////////////////////////////////////////////////////////////////////////////
2890/// Get total size of geometry in bytes.
2891
2893{
2894 Int_t count = 0;
2895 TIter next(fVolumes);
2896 TGeoVolume *vol;
2897 while ((vol = (TGeoVolume *)next()))
2898 count += vol->GetByteCount();
2901 while ((matrix = (TGeoMatrix *)next1()))
2902 count += matrix->GetByteCount();
2905 while ((mat = (TGeoMaterial *)next2()))
2906 count += mat->GetByteCount();
2908 TGeoMedium *med;
2909 while ((med = (TGeoMedium *)next3()))
2910 count += med->GetByteCount();
2911 if (fgVerboseLevel > 0)
2912 Info("GetByteCount", "Total size of logical tree : %i bytes", count);
2913 return count;
2914}
2915
2916////////////////////////////////////////////////////////////////////////////////
2917/// Make a default painter if none present. Returns pointer to it.
2918
2920{
2921 if (!fPainter) {
2922 const char *kind = nullptr;
2923 if (gPad)
2924 kind = gPad->IsWeb() ? "web" : "root";
2925 else
2926 kind = gEnv->GetValue("GeomPainter.Name", "");
2927
2928 if (!kind || !*kind)
2929 kind = (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch()) ? "web" : "root";
2930
2931 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter", kind)) {
2932 if (h->LoadPlugin() == -1) {
2933 Error("GetGeomPainter", "could not load plugin for %s geo_painter", kind);
2934 return nullptr;
2935 }
2936 fPainter = (TVirtualGeoPainter *)h->ExecPlugin(1, this);
2937 if (!fPainter) {
2938 Error("GetGeomPainter", "could not create %s geo_painter", kind);
2939 return nullptr;
2940 }
2941 } else {
2942 Error("GetGeomPainter", "not found plugin %s for geo_painter", kind);
2943 }
2944 }
2945 return fPainter;
2946}
2947
2948////////////////////////////////////////////////////////////////////////////////
2949/// Make a default checker if none present. Returns pointer to it.
2950
2952{
2953 if (!fChecker) {
2954 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoChecker", "root")) {
2955 if (h->LoadPlugin() == -1) {
2956 Error("GetGeomChecker", "could not load plugin for geo_checker");
2957 return nullptr;
2958 }
2959 fChecker = (TVirtualGeoChecker *)h->ExecPlugin(1, this);
2960 if (!fChecker) {
2961 Error("GetGeomChecker", "could not create geo_checker");
2962 return nullptr;
2963 }
2964 } else {
2965 Error("GetGeomChecker", "not found plugin for geo_checker");
2966 }
2967 }
2968 return fChecker;
2969}
2970
2971////////////////////////////////////////////////////////////////////////////////
2972/// Search for a named volume. All trailing blanks stripped.
2973
2975{
2976 TString sname = name;
2977 sname = sname.Strip();
2978 TGeoVolume *vol = (TGeoVolume *)fVolumes->FindObject(sname.Data());
2979 return vol;
2980}
2981
2982////////////////////////////////////////////////////////////////////////////////
2983/// Fast search for a named volume. All trailing blanks stripped.
2984
2986{
2987 if (!fHashVolumes) {
2990 fHashVolumes = new THashList(nvol + 1);
2991 fHashGVolumes = new THashList(ngvol + 1);
2992 Int_t i;
2993 for (i = 0; i < ngvol; i++)
2995 for (i = 0; i < nvol; i++)
2997 }
2998 TString sname = name;
2999 sname = sname.Strip();
3000 THashList *list = fHashVolumes;
3001 if (multi)
3002 list = fHashGVolumes;
3003 TGeoVolume *vol = (TGeoVolume *)list->FindObject(sname.Data());
3004 return vol;
3005}
3006
3007////////////////////////////////////////////////////////////////////////////////
3008/// Retrieve unique id for a volume name. Return -1 if name not found.
3009
3011{
3012 TGeoManager *geom = (TGeoManager *)this;
3013 TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
3014 if (!vol)
3015 vol = geom->FindVolumeFast(volname, kTRUE);
3016 if (!vol)
3017 return -1;
3018 return vol->GetNumber();
3019}
3020
3021////////////////////////////////////////////////////////////////////////////////
3022/// Find if a given material duplicates an existing one.
3023
3025{
3027 if (index <= 0)
3028 return nullptr;
3030 for (Int_t i = 0; i < index; i++) {
3032 if (other == mat)
3033 continue;
3034 if (other->IsEq(mat))
3035 return other;
3036 }
3037 return nullptr;
3038}
3039
3040////////////////////////////////////////////////////////////////////////////////
3041/// Search for a named material. All trailing blanks stripped.
3042
3044{
3046 sname = sname.Strip();
3048 return mat;
3049}
3050
3051////////////////////////////////////////////////////////////////////////////////
3052/// Search for a named tracking medium. All trailing blanks stripped.
3053
3055{
3057 sname = sname.Strip();
3059 return med;
3060}
3061
3062////////////////////////////////////////////////////////////////////////////////
3063/// Search for a tracking medium with a given ID.
3064
3066{
3067 TIter next(fMedia);
3068 TGeoMedium *med;
3069 while ((med = (TGeoMedium *)next())) {
3070 if (med->GetId() == numed)
3071 return med;
3072 }
3073 return nullptr;
3074}
3075
3076////////////////////////////////////////////////////////////////////////////////
3077/// Return material at position id.
3078
3080{
3082 return nullptr;
3084 return mat;
3085}
3086
3087////////////////////////////////////////////////////////////////////////////////
3088/// Return index of named material.
3089
3091{
3092 TIter next(fMaterials);
3094 Int_t id = 0;
3096 sname = sname.Strip();
3097 while ((mat = (TGeoMaterial *)next())) {
3098 if (!strcmp(mat->GetName(), sname.Data()))
3099 return id;
3100 id++;
3101 }
3102 return -1; // fail
3103}
3104
3105////////////////////////////////////////////////////////////////////////////////
3106/// Randomly shoot nrays and plot intersections with surfaces for current
3107/// top node.
3108
3114
3115////////////////////////////////////////////////////////////////////////////////
3116/// Remove material at given index.
3117
3119{
3120 TObject *obj = fMaterials->At(index);
3121 if (obj)
3122 fMaterials->Remove(obj);
3123}
3124
3125////////////////////////////////////////////////////////////////////////////////
3126/// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
3127/// from geometry. Deletion has to be managed by users.
3128
3130{
3131 TIter next(fVolumes);
3132 TGeoVolume *vol;
3133 while ((vol = (TGeoVolume *)next()))
3134 vol->SetField(nullptr);
3135}
3136
3137////////////////////////////////////////////////////////////////////////////////
3138/// Change raytracing mode.
3139
3146
3147////////////////////////////////////////////////////////////////////////////////
3148/// Restore the master volume of the geometry.
3149
3151{
3153 return;
3154 if (fMasterVolume)
3156}
3157
3158////////////////////////////////////////////////////////////////////////////////
3159/// Voxelize all non-divided volumes.
3160
3162{
3163 TGeoVolume *vol;
3164 // TGeoVoxelFinder *vox = 0;
3165 if (!fStreamVoxels && fgVerboseLevel > 0)
3166 Info("Voxelize", "Voxelizing...");
3167 // Int_t nentries = fVolumes->GetSize();
3168 TIter next(fVolumes);
3169 while ((vol = (TGeoVolume *)next())) {
3170 if (!fIsGeomReading)
3171 vol->SortNodes();
3172 if (!fStreamVoxels) {
3173 vol->Voxelize(option);
3174 }
3175 if (!fIsGeomReading)
3176 vol->FindOverlaps();
3177 }
3178}
3179
3180////////////////////////////////////////////////////////////////////////////////
3181/// Send "Modified" signal to painter.
3182
3184{
3185 if (!fPainter)
3186 return;
3188}
3189
3190////////////////////////////////////////////////////////////////////////////////
3191/// Make an TGeoArb8 volume.
3192
3194{
3195 return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
3196}
3197
3198////////////////////////////////////////////////////////////////////////////////
3199/// Make in one step a volume pointing to a box shape with given medium.
3200
3205
3206////////////////////////////////////////////////////////////////////////////////
3207/// Make in one step a volume pointing to a parallelepiped shape with given medium.
3208
3210 Double_t alpha, Double_t theta, Double_t phi)
3211{
3212 return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
3213}
3214
3215////////////////////////////////////////////////////////////////////////////////
3216/// Make in one step a volume pointing to a sphere shape with given medium
3217
3223
3224////////////////////////////////////////////////////////////////////////////////
3225/// Make in one step a volume pointing to a torus shape with given medium.
3226
3232
3233////////////////////////////////////////////////////////////////////////////////
3234/// Make in one step a volume pointing to a tube shape with given medium.
3235
3240
3241////////////////////////////////////////////////////////////////////////////////
3242/// Make in one step a volume pointing to a tube segment shape with given medium.
3243/// The segment will be from phiStart to phiEnd, the angles are expressed in degree
3244
3250
3251////////////////////////////////////////////////////////////////////////////////
3252/// Make in one step a volume pointing to a tube shape with given medium
3253
3255{
3256 return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
3257}
3258
3259////////////////////////////////////////////////////////////////////////////////
3260/// Make in one step a volume pointing to a tube shape with given medium
3261
3267
3268////////////////////////////////////////////////////////////////////////////////
3269/// Make in one step a volume pointing to a tube shape with given medium
3270
3275
3276////////////////////////////////////////////////////////////////////////////////
3277/// Make in one step a volume pointing to a tube segment shape with given medium
3278
3285
3286////////////////////////////////////////////////////////////////////////////////
3287/// Make in one step a volume pointing to a cone shape with given medium.
3288
3294
3295////////////////////////////////////////////////////////////////////////////////
3296/// Make in one step a volume pointing to a cone segment shape with given medium
3297
3303
3304////////////////////////////////////////////////////////////////////////////////
3305/// Make in one step a volume pointing to a polycone shape with given medium.
3306
3308{
3309 return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3310}
3311
3312////////////////////////////////////////////////////////////////////////////////
3313/// Make in one step a volume pointing to a polygone shape with given medium.
3314
3315TGeoVolume *
3317{
3318 return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3319}
3320
3321////////////////////////////////////////////////////////////////////////////////
3322/// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3323
3324TGeoVolume *
3329
3330////////////////////////////////////////////////////////////////////////////////
3331/// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3332
3338
3339////////////////////////////////////////////////////////////////////////////////
3340/// Make in one step a volume pointing to a trapezoid shape with given medium.
3341
3345{
3346 return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2,
3347 alpha2);
3348}
3349
3350////////////////////////////////////////////////////////////////////////////////
3351/// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3352
3360
3361////////////////////////////////////////////////////////////////////////////////
3362/// Make a TGeoXtru-shaped volume with nz planes
3363
3365{
3366 return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3367}
3368
3369////////////////////////////////////////////////////////////////////////////////
3370/// Creates an alignable object with unique name corresponding to a path
3371/// and adds it to the list of alignables. An optional unique ID can be
3372/// provided, in which case PN entries can be searched fast by uid.
3373
3375{
3376 if (!CheckPath(path))
3377 return nullptr;
3378 if (!fHashPNE)
3379 fHashPNE = new THashList(256, 3);
3380 if (!fArrayPNE)
3381 fArrayPNE = new TObjArray(256);
3383 if (entry) {
3384 Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3385 return nullptr;
3386 }
3387 entry = new TGeoPNEntry(unique_name, path);
3389 fHashPNE->Add(entry);
3391 if (uid >= 0) {
3393 if (!added)
3394 Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3395 }
3396 return entry;
3397}
3398
3399////////////////////////////////////////////////////////////////////////////////
3400/// Retrieves an existing alignable object.
3401
3403{
3404 if (!fHashPNE)
3405 return nullptr;
3406 return (TGeoPNEntry *)fHashPNE->FindObject(name);
3407}
3408
3409////////////////////////////////////////////////////////////////////////////////
3410/// Retrieves an existing alignable object at a given index.
3411
3413{
3414 if (!fArrayPNE && !InitArrayPNE())
3415 return nullptr;
3416 return (TGeoPNEntry *)fArrayPNE->At(index);
3417}
3418
3419////////////////////////////////////////////////////////////////////////////////
3420/// Retrieves an existing alignable object having a preset UID.
3421
3423{
3424 if (!fNPNEId || (!fArrayPNE && !InitArrayPNE()))
3425 return nullptr;
3427 if (index < 0 || fKeyPNEId[index] != uid)
3428 return nullptr;
3430}
3431
3432////////////////////////////////////////////////////////////////////////////////
3433/// Retrieves number of PN entries with or without UID.
3434
3436{
3437 if (!fHashPNE)
3438 return 0;
3439 if (with_uid)
3440 return fNPNEId;
3441 return fHashPNE->GetSize();
3442}
3443
3444////////////////////////////////////////////////////////////////////////////////
3445/// Insert a PN entry in the sorted array of indexes.
3446
3448{
3449 if (!fSizePNEId) {
3450 // Create the arrays.
3451 fSizePNEId = 128;
3452 fKeyPNEId = new Int_t[fSizePNEId];
3453 memset(fKeyPNEId, 0, fSizePNEId * sizeof(Int_t));
3455 memset(fValuePNEId, 0, fSizePNEId * sizeof(Int_t));
3456 fKeyPNEId[fNPNEId] = uid;
3458 return kTRUE;
3459 }
3460 // Search id in the existing array and return false if it already exists.
3462 if (index > 0 && fKeyPNEId[index] == uid)
3463 return kFALSE;
3464 // Resize the arrays and insert the value
3465 Bool_t resize = (fNPNEId == fSizePNEId) ? kTRUE : kFALSE;
3466 if (resize) {
3467 // Double the size of the array
3468 fSizePNEId *= 2;
3469 // Create new arrays of keys and values
3470 Int_t *keys = new Int_t[fSizePNEId];
3471 memset(keys, 0, fSizePNEId * sizeof(Int_t));
3472 Int_t *values = new Int_t[fSizePNEId];
3473 memset(values, 0, fSizePNEId * sizeof(Int_t));
3474 // Copy all keys<uid in the new keys array (0 to index)
3475 memcpy(keys, fKeyPNEId, (index + 1) * sizeof(Int_t));
3476 memcpy(values, fValuePNEId, (index + 1) * sizeof(Int_t));
3477 // Insert current key at index+1
3478 keys[index + 1] = uid;
3479 values[index + 1] = ientry;
3480 // Copy all remaining keys from the old to new array
3481 memcpy(&keys[index + 2], &fKeyPNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3482 memcpy(&values[index + 2], &fValuePNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3483 delete[] fKeyPNEId;
3484 fKeyPNEId = keys;
3485 delete[] fValuePNEId;
3486 fValuePNEId = values;
3487 fNPNEId++;
3488 return kTRUE;
3489 }
3490 // Insert the value in the existing arrays
3491 Int_t i;
3492 for (i = fNPNEId - 1; i > index; i--) {
3493 fKeyPNEId[i + 1] = fKeyPNEId[i];
3494 fValuePNEId[i + 1] = fValuePNEId[i];
3495 }
3496 fKeyPNEId[index + 1] = uid;
3497 fValuePNEId[index + 1] = ientry;
3498 fNPNEId++;
3499 return kTRUE;
3500}
3501
3502////////////////////////////////////////////////////////////////////////////////
3503/// Make a physical node from the path pointed by an alignable object with a given name.
3504
3506{
3508 if (!entry) {
3509 Error("MakeAlignablePN", "No alignable object named %s found !", name);
3510 return nullptr;
3511 }
3512 return MakeAlignablePN(entry);
3513}
3514
3515////////////////////////////////////////////////////////////////////////////////
3516/// Make a physical node from the path pointed by a given alignable object.
3517
3519{
3520 if (!entry) {
3521 Error("MakeAlignablePN", "No alignable object specified !");
3522 return nullptr;
3523 }
3524 const char *path = entry->GetTitle();
3525 if (!cd(path)) {
3526 Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s", entry->GetName(), path);
3527 return nullptr;
3528 }
3529 TGeoPhysicalNode *node = MakePhysicalNode(path);
3530 entry->SetPhysicalNode(node);
3531 return node;
3532}
3533
3534////////////////////////////////////////////////////////////////////////////////
3535/// Makes a physical node corresponding to a path. If PATH is not specified,
3536/// makes physical node matching current modeller state.
3537
3539{
3540 TGeoPhysicalNode *node;
3541 if (path) {
3542 if (!CheckPath(path)) {
3543 Error("MakePhysicalNode", "path: %s not valid", path);
3544 return nullptr;
3545 }
3546 node = new TGeoPhysicalNode(path);
3547 } else {
3548 node = new TGeoPhysicalNode(GetPath());
3549 }
3550 fPhysicalNodes->Add(node);
3551 return node;
3552}
3553
3554////////////////////////////////////////////////////////////////////////////////
3555/// Refresh physical nodes to reflect the actual geometry paths after alignment
3556/// was applied. Optionally locks physical nodes (default).
3557
3559{
3562 while ((pn = (TGeoPhysicalNode *)next()))
3563 pn->Refresh();
3566 if (lock)
3567 LockGeometry();
3568}
3569
3570////////////////////////////////////////////////////////////////////////////////
3571/// Clear the current list of physical nodes, so that we can start over with a new list.
3572/// If MUSTDELETE is true, delete previous nodes.
3573
3581
3582////////////////////////////////////////////////////////////////////////////////
3583/// Make an assembly of volumes.
3584
3586{
3587 return TGeoBuilder::Instance(this)->MakeVolumeAssembly(name);
3588}
3589
3590////////////////////////////////////////////////////////////////////////////////
3591/// Make a TGeoVolumeMulti handling a list of volumes.
3592
3594{
3595 return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3596}
3597
3598////////////////////////////////////////////////////////////////////////////////
3599/// Set type of exploding view (see TGeoPainter::SetExplodedView())
3600
3602{
3603 if ((ibomb >= 0) && (ibomb < 4))
3605 if (fPainter)
3607}
3608
3609////////////////////////////////////////////////////////////////////////////////
3610/// Set cut phi range
3611
3613{
3614 if ((phimin == 0) && (phimax == 360)) {
3615 fPhiCut = kFALSE;
3616 return;
3617 }
3618 fPhiCut = kTRUE;
3619 fPhimin = phimin;
3620 fPhimax = phimax;
3621}
3622
3623////////////////////////////////////////////////////////////////////////////////
3624/// Set number of segments for approximating circles in drawing.
3625
3627{
3628 if (fNsegments == nseg)
3629 return;
3630 if (nseg > 2)
3631 fNsegments = nseg;
3632 if (fPainter)
3634}
3635
3636////////////////////////////////////////////////////////////////////////////////
3637/// Get number of segments approximating circles
3638
3640{
3641 return fNsegments;
3642}
3643
3644////////////////////////////////////////////////////////////////////////////////
3645/// Now just a shortcut for GetElementTable.
3646
3652
3653////////////////////////////////////////////////////////////////////////////////
3654/// Returns material table. Creates it if not existing.
3655
3662
3663////////////////////////////////////////////////////////////////////////////////
3664/// Make a rectilinear step of length fStep from current point (fPoint) on current
3665/// direction (fDirection). If the step is imposed by geometry, is_geom flag
3666/// must be true (default). The cross flag specifies if the boundary should be
3667/// crossed in case of a geometry step (default true). Returns new node after step.
3668/// Set also on boundary condition.
3669
3671{
3672 return GetCurrentNavigator()->Step(is_geom, cross);
3673}
3674
3675////////////////////////////////////////////////////////////////////////////////
3676/// shoot npoints randomly in a box of 1E-5 around current point.
3677/// return minimum distance to points outside
3678
3683
3684////////////////////////////////////////////////////////////////////////////////
3685/// Set the top volume and corresponding node as starting point of the geometry.
3686
3688{
3689 if (fTopVolume == vol)
3690 return;
3691
3692 TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3693 TIter next(brlist);
3694 TBrowser *browser = nullptr;
3695
3696 if (fTopVolume)
3697 fTopVolume->SetTitle("");
3698 fTopVolume = vol;
3699 vol->SetTitle("Top volume");
3700 if (fTopNode) {
3702 fTopNode = nullptr;
3703 while ((browser = (TBrowser *)next()))
3704 browser->RecursiveRemove(topn);
3705 delete topn;
3706 } else {
3707 fMasterVolume = vol;
3710 if (fgVerboseLevel > 0)
3711 Info("SetTopVolume", "Top volume is %s. Master volume is %s", fTopVolume->GetName(), fMasterVolume->GetName());
3712 }
3713 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3714 // fCurrentMatrix->Print();
3716 fTopNode->SetName(TString::Format("%s_1", vol->GetName()));
3717 fTopNode->SetNumber(1);
3718 fTopNode->SetTitle("Top logical node");
3719 fNodes->AddAt(fTopNode, 0);
3720 if (!GetCurrentNavigator()) {
3722 return;
3723 }
3724 Int_t nnavigators = 0;
3726 if (!arr)
3727 return;
3728 nnavigators = arr->GetEntriesFast();
3729 for (Int_t i = 0; i < nnavigators; i++) {
3730 TGeoNavigator *nav = (TGeoNavigator *)arr->At(i);
3731 nav->ResetAll();
3732 if (fClosed)
3733 nav->GetCache()->BuildInfoBranch();
3734 }
3735}
3736
3737////////////////////////////////////////////////////////////////////////////////
3738/// Define different tracking media.
3739
3741{
3742 /*
3743 Int_t nmat = fMaterials->GetSize();
3744 if (!nmat) {printf(" No materials !\n"); return;}
3745 Int_t *media = new Int_t[nmat];
3746 memset(media, 0, nmat*sizeof(Int_t));
3747 Int_t imedia = 1;
3748 TGeoMaterial *mat, *matref;
3749 mat = (TGeoMaterial*)fMaterials->At(0);
3750 if (mat->GetMedia()) {
3751 for (Int_t i=0; i<nmat; i++) {
3752 mat = (TGeoMaterial*)fMaterials->At(i);
3753 mat->Print();
3754 }
3755 return;
3756 }
3757 mat->SetMedia(imedia);
3758 media[0] = imedia++;
3759 mat->Print();
3760 for (Int_t i=0; i<nmat; i++) {
3761 mat = (TGeoMaterial*)fMaterials->At(i);
3762 for (Int_t j=0; j<i; j++) {
3763 matref = (TGeoMaterial*)fMaterials->At(j);
3764 if (mat->IsEq(matref)) {
3765 mat->SetMedia(media[j]);
3766 break;
3767 }
3768 if (j==(i-1)) {
3769 // different material
3770 mat->SetMedia(imedia);
3771 media[i] = imedia++;
3772 mat->Print();
3773 }
3774 }
3775 }
3776 */
3777}
3778
3779////////////////////////////////////////////////////////////////////////////////
3780/// Check pushes and pulls needed to cross the next boundary with respect to the
3781/// position given by FindNextBoundary. If radius is not mentioned the full bounding
3782/// box will be sampled.
3783
3788
3789////////////////////////////////////////////////////////////////////////////////
3790/// Check the boundary errors reference file created by CheckBoundaryErrors method.
3791/// The shape for which the crossing failed is drawn with the starting point in red
3792/// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3793
3798
3799////////////////////////////////////////////////////////////////////////////////
3800/// Classify a given point. See TGeoChecker::CheckPoint().
3801
3806
3807////////////////////////////////////////////////////////////////////////////////
3808/// Test for shape navigation methods. Summary for test numbers:
3809/// - 1: DistFromInside/Outside. Sample points inside the shape. Generate
3810/// directions randomly in cos(theta). Compute DistFromInside and move the
3811/// point with bigger distance. Compute DistFromOutside back from new point.
3812/// Plot d-(d1+d2)
3813///
3814
3819
3820////////////////////////////////////////////////////////////////////////////////
3821/// Geometry checking.
3822/// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3823/// - if option contains 'b': Optional boundary crossing check + timing per volume.
3824///
3825/// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3826/// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3827/// be called for the suspicious volumes.
3828///
3829/// STAGE 2: normal overlap checking using the shapes mesh - fills the list of
3830/// overlaps.
3831///
3832/// STAGE 3: shooting NRAYS rays from VERTEX and counting the total number of
3833/// crossings per volume (rays propagated from boundary to boundary until
3834/// geometry exit). Timing computed and results stored in a histo.
3835///
3836/// STAGE 4: shooting 1 mil. random rays inside EACH volume and calling
3837/// FindNextBoundary() + Safety() for each call. The timing is normalized by the
3838/// number of crossings computed at stage 2 and presented as percentage.
3839/// One can get a picture on which are the most "burned" volumes during
3840/// transportation from geometry point of view. Another plot of the timing per
3841/// volume vs. number of daughters is produced.
3842
3844{
3845 TString opt(option);
3846 opt.ToLower();
3847 if (!opt.Length()) {
3848 Error("CheckGeometryFull", "The option string must contain a letter. See method documentation.");
3849 return;
3850 }
3851 Bool_t checkoverlaps = opt.Contains("o");
3852 Bool_t checkcrossings = opt.Contains("b");
3853 Double_t vertex[3];
3854 vertex[0] = vx;
3855 vertex[1] = vy;
3856 vertex[2] = vz;
3858}
3859
3860////////////////////////////////////////////////////////////////////////////////
3861/// Perform last checks on the geometry
3862
3864{
3865 if (fgVerboseLevel > 0)
3866 Info("CheckGeometry", "Fixing runtime shapes...");
3867 TIter next(fShapes);
3869 TGeoShape *shape;
3870 TGeoVolume *vol;
3872 while ((shape = (TGeoShape *)next())) {
3873 if (shape->IsRunTimeShape()) {
3875 }
3876 if (fIsGeomReading)
3877 shape->AfterStreamer();
3880 shape->ComputeBBox();
3881 }
3882 if (has_runtime)
3884 else if (fgVerboseLevel > 0)
3885 Info("CheckGeometry", "...Nothing to fix");
3886 // Compute bounding box for assemblies
3888 while ((vol = (TGeoVolume *)nextv())) {
3889 if (vol->IsAssembly())
3890 vol->GetShape()->ComputeBBox();
3891 else if (vol->GetMedium() == dummy) {
3892 Warning("CheckGeometry", "Volume \"%s\" has no medium: assigned dummy medium and material", vol->GetName());
3893 vol->SetMedium(dummy);
3894 }
3895 }
3896}
3897
3898////////////////////////////////////////////////////////////////////////////////
3899/// Check all geometry for illegal overlaps within a limit OVLP.
3900
3902{
3903 if (!fTopNode) {
3904 Error("CheckOverlaps", "Top node not set");
3905 return;
3906 }
3908}
3909
3910////////////////////////////////////////////////////////////////////////////////
3911/// Prints the current list of overlaps.
3912
3914{
3915 if (!fOverlaps)
3916 return;
3918 if (!novlp)
3919 return;
3920 TGeoManager *geom = (TGeoManager *)this;
3921 geom->GetGeomChecker()->PrintOverlaps();
3922}
3923
3924////////////////////////////////////////////////////////////////////////////////
3925/// Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
3926/// Option can be "v" - verbose (default)
3927
3929{
3930 if (!GetGeomChecker())
3931 return 0.;
3932 TString opt(option);
3933 opt.ToLower();
3934 Double_t weight;
3935 TGeoVolume *volume = fTopVolume;
3936 if (opt.Contains("v")) {
3937 if (opt.Contains("a")) {
3938 if (fgVerboseLevel > 0)
3939 Info("Weight", "Computing analytically weight of %s", volume->GetName());
3940 weight = volume->WeightA();
3941 if (fgVerboseLevel > 0)
3942 Info("Weight", "Computed weight: %f [kg]\n", weight);
3943 return weight;
3944 }
3945 if (fgVerboseLevel > 0) {
3946 Info("Weight", "Estimating weight of %s with %g %% precision", fTopVolume->GetName(), 100. * precision);
3947 printf(" event weight err\n");
3948 printf("========================================\n");
3949 }
3950 }
3951 weight = fChecker->Weight(precision, option);
3952 return weight;
3953}
3954
3955////////////////////////////////////////////////////////////////////////////////
3956/// computes the total size in bytes of the branch starting with node.
3957/// The option can specify if all the branch has to be parsed or only the node
3958
3959ULong_t TGeoManager::SizeOf(const TGeoNode * /*node*/, Option_t * /*option*/)
3960{
3961 return 0;
3962}
3963
3964////////////////////////////////////////////////////////////////////////////////
3965/// Stream an object of class TGeoManager.
3966
3968{
3969 if (R__b.IsReading()) {
3970 R__b.ReadClassBuffer(TGeoManager::Class(), this);
3972 CloseGeometry();
3975 } else {
3976 R__b.WriteClassBuffer(TGeoManager::Class(), this);
3977 }
3978}
3979
3980////////////////////////////////////////////////////////////////////////////////
3981/// Execute mouse actions on this manager.
3982
3984{
3985 if (!fPainter)
3986 return;
3987 fPainter->ExecuteManagerEvent(this, event, px, py);
3988}
3989
3990////////////////////////////////////////////////////////////////////////////////
3991/// Export this geometry to a file
3992///
3993/// - Case 1: root file or root/xml file
3994/// if filename end with ".root". The key will be named name
3995/// By default the geometry is saved without the voxelisation info.
3996/// Use option 'v" to save the voxelisation info.
3997/// if filename end with ".xml" a root/xml file is produced.
3998///
3999/// - Case 2: C++ script
4000/// if filename end with ".C"
4001///
4002/// - Case 3: gdml file
4003/// if filename end with ".gdml"
4004/// NOTE that to use this option, the PYTHONPATH must be defined like
4005/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/geom/gdml
4006///
4007
4009{
4011 if (sfile.Contains(".C")) {
4012 // Save geometry as a C++ script
4013 if (fgVerboseLevel > 0)
4014 Info("Export", "Exporting %s %s as C++ code", GetName(), GetTitle());
4016 return 1;
4017 }
4018 if (sfile.Contains(".gdml")) {
4019 // Save geometry as a gdml file
4020 if (fgVerboseLevel > 0)
4021 Info("Export", "Exporting %s %s as gdml code", GetName(), GetTitle());
4022 // C++ version
4023 TString cmd;
4024 cmd = TString::Format("TGDMLWrite::StartGDMLWriting(gGeoManager,\"%s\",\"%s\")", filename, option);
4025 gROOT->ProcessLineFast(cmd);
4026 return 1;
4027 }
4028 if (sfile.Contains(".root") || sfile.Contains(".xml")) {
4029 // Save geometry as a root file
4030 TFile *f = TFile::Open(filename, "recreate");
4031 if (!f || f->IsZombie()) {
4032 Error("Export", "Cannot open file");
4033 return 0;
4034 }
4036 if (keyname.IsNull())
4037 keyname = GetName();
4038 TString opt = option;
4039 opt.ToLower();
4040 if (opt.Contains("v")) {
4042 if (fgVerboseLevel > 0)
4043 Info("Export", "Exporting %s %s as root file. Optimizations streamed.", GetName(), GetTitle());
4044 } else {
4046 if (fgVerboseLevel > 0)
4047 Info("Export", "Exporting %s %s as root file. Optimizations not streamed.", GetName(), GetTitle());
4048 }
4049
4053 if (sfile.Contains(".xml")) {
4056 }
4058 if (sfile.Contains(".xml")) {
4061 }
4062
4064 delete f;
4065 return nbytes;
4066 }
4067 return 0;
4068}
4069
4070////////////////////////////////////////////////////////////////////////////////
4071/// Lock current geometry so that no other geometry can be imported.
4072
4074{
4075 fgLock = kTRUE;
4076}
4077
4078////////////////////////////////////////////////////////////////////////////////
4079/// Unlock current geometry.
4080
4082{
4083 fgLock = kFALSE;
4084}
4085
4086////////////////////////////////////////////////////////////////////////////////
4087/// Check lock state.
4088
4090{
4091 return fgLock;
4092}
4093
4094////////////////////////////////////////////////////////////////////////////////
4095/// Set verbosity level (static function).
4096/// - 0 - suppress messages related to geom-painter visibility level
4097/// - 1 - default value
4098
4103
4104////////////////////////////////////////////////////////////////////////////////
4105/// Return current verbosity level (static function).
4106
4111
4112////////////////////////////////////////////////////////////////////////////////
4113/// static function
4114/// Import a geometry from a gdml or ROOT file
4115///
4116/// - Case 1: gdml
4117/// if filename ends with ".gdml" the foreign geometry described with gdml
4118/// is imported executing some python scripts in $ROOTSYS/gdml.
4119/// NOTE that to use this option, the PYTHONPATH must be defined like
4120/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
4121///
4122/// - Case 2: root file (.root) or root/xml file (.xml)
4123/// Import in memory from filename the geometry with key=name.
4124/// if name="" (default), the first TGeoManager object in the file is returned.
4125///
4126/// Note that this function deletes the current gGeoManager (if one)
4127/// before importing the new object.
4128
4129TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
4130{
4131 if (fgLock) {
4132 ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
4133 return nullptr;
4134 }
4135 if (!filename)
4136 return nullptr;
4137 if (fgVerboseLevel > 0)
4138 ::Info("TGeoManager::Import", "Reading geometry from file: %s", filename);
4139
4140 if (gGeoManager)
4141 delete gGeoManager;
4142 gGeoManager = nullptr;
4143
4144 if (strstr(filename, ".gdml")) {
4145 // import from a gdml file
4146 new TGeoManager("GDMLImport", "Geometry imported from GDML");
4147 TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
4148 TGeoVolume *world = (TGeoVolume *)gROOT->ProcessLineFast(cmd);
4149
4150 if (world == nullptr) {
4151 delete gGeoManager;
4152 gGeoManager = nullptr;
4153 ::Error("TGeoManager::Import", "Cannot read file %s", filename);
4154 } else {
4158 }
4159 } else {
4160 // import from a root file
4162 // in case a web file is specified, use the cacheread option to cache
4163 // this file in the cache directory
4164 TFile *f = nullptr;
4165 if (strstr(filename, "http"))
4166 f = TFile::Open(filename, "CACHEREAD");
4167 else
4169 if (!f || f->IsZombie()) {
4170 ::Error("TGeoManager::Import", "Cannot open file");
4171 return nullptr;
4172 }
4173 if (name && strlen(name) > 0) {
4174 gGeoManager = (TGeoManager *)f->Get(name);
4175 } else {
4176 TIter next(f->GetListOfKeys());
4177 TKey *key;
4178 while ((key = (TKey *)next())) {
4179 if (strcmp(key->GetClassName(), "TGeoManager") != 0)
4180 continue;
4181 gGeoManager = (TGeoManager *)key->ReadObj();
4182 break;
4183 }
4184 }
4185 delete f;
4186 }
4187 if (!gGeoManager)
4188 return nullptr;
4189 if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager))
4190 gROOT->GetListOfGeometries()->Add(gGeoManager);
4191 if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager))
4192 gROOT->GetListOfBrowsables()->Add(gGeoManager);
4194 return gGeoManager;
4195}
4196
4197////////////////////////////////////////////////////////////////////////////////
4198/// Update element flags when geometry is loaded from a file.
4199
4201{
4202 if (!fElementTable)
4203 return;
4204 TIter next(fMaterials);
4206 TGeoMixture *mix;
4208 Int_t i, nelem;
4209 while ((mat = (TGeoMaterial *)next())) {
4210 if (mat->IsMixture()) {
4211 mix = (TGeoMixture *)mat;
4212 nelem = mix->GetNelements();
4213 for (i = 0; i < nelem; i++) {
4214 elem = mix->GetElement(i);
4215 if (!elem)
4216 continue;
4218 if (!elem_table)
4219 continue;
4220 if (elem != elem_table) {
4221 elem_table->SetDefined(elem->IsDefined());
4222 elem_table->SetUsed(elem->IsUsed());
4223 } else {
4224 elem_table->SetDefined();
4225 }
4226 }
4227 } else {
4228 elem = mat->GetElement();
4229 if (!elem)
4230 continue;
4232 if (!elem_table)
4233 continue;
4234 if (elem != elem_table) {
4235 elem_table->SetDefined(elem->IsDefined());
4236 elem_table->SetUsed(elem->IsUsed());
4237 } else {
4238 elem_table->SetUsed();
4239 }
4240 }
4241 }
4242}
4243
4244////////////////////////////////////////////////////////////////////////////////
4245/// Initialize PNE array for fast access via index and unique-id.
4246
4248{
4249 if (fHashPNE) {
4251 TIter next(fHashPNE);
4252 TObject *obj;
4253 while ((obj = next())) {
4254 fArrayPNE->Add(obj);
4255 }
4256 return kTRUE;
4257 }
4258 return kFALSE;
4259}
4260
4261////////////////////////////////////////////////////////////////////////////////
4262/// Get time cut for drawing tracks.
4263
4265{
4266 tmin = fTmin;
4267 tmax = fTmax;
4268 return fTimeCut;
4269}
4270
4271////////////////////////////////////////////////////////////////////////////////
4272/// Set time cut interval for drawing tracks. If called with no arguments, time
4273/// cut will be disabled.
4274
4276{
4277 fTmin = tmin;
4278 fTmax = tmax;
4279 if (tmin == 0 && tmax == 999)
4280 fTimeCut = kFALSE;
4281 else
4282 fTimeCut = kTRUE;
4283 if (fTracks && !IsAnimatingTracks())
4284 ModifiedPad();
4285}
4286
4287////////////////////////////////////////////////////////////////////////////////
4288/// Convert coordinates from master volume frame to top.
4289
4294
4295////////////////////////////////////////////////////////////////////////////////
4296/// Convert coordinates from top volume frame to master.
4297
4302
4303////////////////////////////////////////////////////////////////////////////////
4304/// Create a parallel world for prioritised navigation. This can be populated
4305/// with physical nodes and can be navigated independently using its API.
4306/// In case the flag SetUseParallelWorldNav is set, any navigation query in the
4307/// main geometry is checked against the parallel geometry, which gets priority
4308/// in case of overlaps with the main geometry volumes.
4309
4315
4316////////////////////////////////////////////////////////////////////////////////
4317/// Activate/deactivate usage of parallel world navigation. Can only be done if
4318/// there is a parallel world. Activating navigation will automatically close
4319/// the parallel geometry.
4320
4322{
4323 if (!fParallelWorld) {
4324 Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
4325 return;
4326 }
4327 if (!flag) {
4328 fUsePWNav = flag;
4329 return;
4330 }
4331 if (!fClosed) {
4332 Error("SetUseParallelWorldNav", "The geometry must be closed first");
4333 return;
4334 }
4335 // Closing the parallel world geometry is mandatory
4337 fUsePWNav = kTRUE;
4338}
4339
4346
4351
4353{
4354 if (fgDefaultUnits == new_value) {
4355 gGeometryLocked = true;
4356 return;
4357 } else if (gGeometryLocked) {
4358 ::Fatal("TGeoManager", "The system of units may only be changed once, \n"
4359 "BEFORE any elements and materials are created! \n"
4360 "Alternatively unlock the default units at own risk.");
4361 } else if (new_value == kG4Units) {
4362 ::Info("TGeoManager", "Changing system of units to Geant4 units (mm, ns, MeV).");
4363 } else if (new_value == kRootUnits) {
4364 ::Info("TGeoManager", "Changing system of units to ROOT units (cm, s, GeV).");
4365 }
4367}
4368
4373
#define SafeDelete(p)
Definition RConfig.hxx:533
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
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
@ kGray
Definition Rtypes.h:66
@ kRed
Definition Rtypes.h:67
@ kOrange
Definition Rtypes.h:68
@ kGreen
Definition Rtypes.h:67
@ kMagenta
Definition Rtypes.h:67
@ kBlue
Definition Rtypes.h:67
@ kYellow
Definition Rtypes.h:67
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
char name[80]
Definition TGX11.cxx:110
TGeoManager * gGeoManager
static Bool_t gGeometryLocked
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TGeoIdentity * gGeoIdentity
Definition TGeoMatrix.h:537
int nentries
#define gROOT
Definition TROOT.h:411
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:490
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx: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:17
static TGeoBuilder * Instance(TGeoManager *geom)
Return pointer to singleton.
Class describing rotation + translation.
Definition TGeoMatrix.h:317
Composite shapes are Boolean combinations of two or more shape components.
table of elements
TGeoElement * GetElement(Int_t z)
Base class for chemical elements.
Definition TGeoElement.h:31
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition TGeoMatrix.h:458
An identity transformation.
Definition TGeoMatrix.h:406
A geometry iterator.
Definition TGeoNode.h:248
Int_t GetLevel() const
Definition TGeoNode.h:294
The manager class for any TGeo geometry.
Definition TGeoManager.h:45
static void UnlockGeometry()
Unlock current geometry.
Double_t fPhimax
lowest range for phi cut
Definition TGeoManager.h:64
TGeoVolume * MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
Make in one step a volume pointing to a cone shape with given medium.
void AnimateTracks(Double_t tmin=0, Double_t tmax=5E-8, Int_t nframes=200, Option_t *option="/*")
Draw animation of tracks.
void AddSkinSurface(TGeoSkinSurface *surf)
Add skin surface;.
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
TGeoVolume * MakePcon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nz)
Make in one step a volume pointing to a polycone shape with given medium.
Int_t fRaytraceMode
Flag for multi-threading.
Double_t fVisDensity
particles to be drawn
Definition TGeoManager.h:70
TGeoNavigator * AddNavigator()
Add a navigator in the list of navigators.
TVirtualGeoTrack * GetTrackOfId(Int_t id) const
Get track with a given ID.
TGeoMaterial * FindDuplicateMaterial(const TGeoMaterial *mat) const
Find if a given material duplicates an existing one.
TGeoVolume * Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Create a new volume by dividing an existing one (GEANT3 like)
TGeoVolume * Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar=0)
Create a volume in GEANT3 style.
Int_t ReplaceVolume(TGeoVolume *vorig, TGeoVolume *vnew)
Replaces all occurrences of VORIG with VNEW in the geometry tree.
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
Int_t GetCurrentNodeId() const
Get the unique ID of the current node.
TGeoPNEntry * GetAlignableEntry(const char *name) const
Retrieves an existing alignable object.
TGeoVolume * fMasterVolume
top physical node
TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Search the track hierarchy to find the track with the given id.
TObjArray * fArrayPNE
void TestOverlaps(const char *path="")
Geometry overlap checker based on sampling.
static EDefaultUnits GetDefaultUnits()
void RemoveMaterial(Int_t index)
Remove material at given index.
void Matrix(Int_t index, Double_t theta1, Double_t phi1, Double_t theta2, Double_t phi2, Double_t theta3, Double_t phi3)
Create rotation matrix named 'mat<index>'.
TGeoElementTable * GetElementTable()
Returns material table. Creates it if not existing.
Int_t fNtracks
Definition TGeoManager.h:75
THashList * fHashPNE
hash list of group volumes providing fast search
static Int_t fgVerboseLevel
Lock preventing a second geometry to be loaded.
Definition TGeoManager.h:52
void Init()
Initialize manager class.
Bool_t InitArrayPNE() const
Initialize PNE array for fast access via index and unique-id.
TObjArray * fPhysicalNodes
Definition TGeoManager.h:98
virtual ULong_t SizeOf(const TGeoNode *node, Option_t *option)
computes the total size in bytes of the branch starting with node.
TObjArray * fUniqueVolumes
static UInt_t fgExportPrecision
Maximum number of Xtru vertices.
Definition TGeoManager.h:56
TObjArray * fRegions
void Node(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, Bool_t isOnly, Float_t *upar, Int_t npar=0)
Create a node called <name_nr> pointing to the volume called <name> as daughter of the volume called ...
TObjArray * fGShapes
Definition TGeoManager.h:99
TGeoVolume * fPaintVolume
TGeoSkinSurface * GetSkinSurface(const char *name) const
Get skin surface with a given name;.
void UpdateElements()
Update element flags when geometry is loaded from a file.
TGeoManager()
Default constructor.
TVirtualGeoChecker * GetGeomChecker()
Make a default checker if none present. Returns pointer to it.
static TClass * Class()
ConstPropMap_t fProperties
TGeoVolume * MakeTube(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
void CdUp()
Go one level up in geometry.
void DoBackupState()
Backup the current state without affecting the cache stack.
TList * fMaterials
void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)
Check pushes and pulls needed to cross the next boundary with respect to the position given by FindNe...
TObjArray * fVolumes
Definition TGeoManager.h:97
Int_t * fValuePNEId
TGeoPNEntry * GetAlignableEntryByUID(Int_t uid) const
Retrieves an existing alignable object having a preset UID.
void AddGDMLMatrix(TGDMLMatrix *mat)
Add GDML matrix;.
Bool_t fTimeCut
Definition TGeoManager.h:86
static void SetExportPrecision(UInt_t prec)
void AddBorderSurface(TGeoBorderSurface *surf)
Add border surface;.
void SetClippingShape(TGeoShape *clip)
Set a user-defined shape as clipping for ray tracing.
TGeoVolume * fCurrentVolume
current navigator
void ClearOverlaps()
Clear the list of overlaps.
TGeoVolume * MakeCons(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a cone segment shape with given medium.
THashList * fHashGVolumes
hash list of volumes providing fast search
TVirtualGeoChecker * fChecker
current painter
Definition TGeoManager.h:93
Int_t fVisOption
Definition TGeoManager.h:72
static std::mutex fgMutex
Definition TGeoManager.h:50
Bool_t IsInPhiRange() const
True if current node is in phi range.
virtual Bool_t cd(const char *path="")
Browse the tree of nodes starting from fTopNode according to pathname.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=nullptr)
Returns the deepest node containing fPoint, which must be set a priori.
TGeoMaterial * Material(const char *name, Double_t a, Double_t z, Double_t dens, Int_t uid, Double_t radlen=0, Double_t intlen=0)
Create material with given A, Z and density, having an unique id.
void LocalToMaster(const Double_t *local, Double_t *master) const
Double_t fPhimin
Definition TGeoManager.h:63
static Bool_t fgLockNavigators
Number of registered threads.
void SaveAttributes(const char *filename="tgeoatt.C")
Save current attributes in a macro.
void RestoreMasterVolume()
Restore the master volume of the geometry.
Bool_t fDrawExtra
Definition TGeoManager.h:87
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=nullptr)
Make an TGeoArb8 volume.
virtual Int_t Export(const char *filename, const char *name="", Option_t *option="vg")
Export this geometry to a file.
TGeoNode * FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE)
Computes as fStep the distance to next daughter of the current volume.
Int_t GetUID(const char *volname) const
Retrieve unique id for a volume name. Return -1 if name not found.
TGeoShape * fClippingShape
TGeoNavigator * GetCurrentNavigator() const
Returns current navigator for the calling thread.
THashList * fHashVolumes
TObjArray * fMatrices
current checker
Definition TGeoManager.h:95
static Int_t GetNumThreads()
Returns number of threads that were set to use geometry.
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
void ClearNavigators()
Clear all navigators.
Int_t AddTransformation(const TGeoMatrix *matrix)
Add a matrix to the list. Returns index of the matrix in list.
TObjArray * fOpticalSurfaces
TVirtualGeoTrack * GetParentTrackOfId(Int_t id) const
Get parent track with a given ID.
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
UChar_t * fBits
static Int_t GetMaxLevels()
Return maximum number of levels used in the geometry.
Double_t fTmin
highest range for phi cut
Definition TGeoManager.h:65
static Bool_t IsLocked()
Check lock state.
TGeoVolume * fTopVolume
current volume
TGeoVolume * fUserPaintVolume
volume currently painted
TVirtualGeoPainter * GetGeomPainter()
Make a default painter if none present. Returns pointer to it.
void GetBranchOnlys(Int_t *isonly) const
Fill node copy numbers of current branch into an array.
TGeoNode * GetCurrentNode() const
Int_t AddTrack(Int_t id, Int_t pdgcode, TObject *particle=nullptr)
Add a track to the list of tracks.
void SetVisOption(Int_t option=0)
set drawing mode :
void SetPdgName(Int_t pdg, const char *name)
Set a name for a particle having a given pdg.
TObjArray * fBorderSurfaces
Int_t GetNAlignable(Bool_t with_uid=kFALSE) const
Retrieves number of PN entries with or without UID.
void RefreshPhysicalNodes(Bool_t lock=kTRUE)
Refresh physical nodes to reflect the actual geometry paths after alignment was applied.
static Bool_t fgLock
mutex for navigator booking in MT mode
Definition TGeoManager.h:51
TGeoVolume * MakePara(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz, Double_t alpha, Double_t theta, Double_t phi)
Make in one step a volume pointing to a parallelepiped shape with given medium.
void TopToMaster(const Double_t *top, Double_t *master) const
Convert coordinates from top volume frame to master.
TObjArray * fShapes
Definition TGeoManager.h:96
void AddOpticalSurface(TGeoOpticalSurface *optsurf)
Add optical surface;.
static void SetDefaultUnits(EDefaultUnits new_value)
Bool_t fLoopVolumes
flag that geometry is closed
Definition TGeoManager.h:81
Int_t AddMaterial(const TGeoMaterial *material)
Add a material to the list. Returns index of the material in list.
void ClearAttributes()
Reset all attributes to default ones.
static Int_t fgMaxDaughters
Maximum level in geometry.
Definition TGeoManager.h:54
Bool_t fUsePWNav
Raytrace mode: 0=normal, 1=pass through, 2=transparent.
void SetRTmode(Int_t mode)
Change raytracing mode.
Bool_t CheckPath(const char *path) const
Check if a geometry path is valid without changing the state of the current navigator.
void InspectState() const
Inspects path and all flags for the current state.
void ConvertReflections()
Convert all reflections in geometry to normal rotations + reflected shapes.
void SetVisLevel(Int_t level=3)
set default level down to which visualization is performed
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
TGeoPhysicalNode * MakePhysicalNode(const char *path=nullptr)
Makes a physical node corresponding to a path.
void CountLevels()
Count maximum number of nodes per volume, maximum depth and maximum number of xtru vertices.
Int_t fMaxThreads
Bool_t fIsGeomReading
Definition TGeoManager.h:83
TGeoVolume * MakeTorus(const char *name, TGeoMedium *medium, Double_t r, Double_t rmin, Double_t rmax, Double_t phi1=0, Double_t dphi=360)
Make in one step a volume pointing to a torus shape with given medium.
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
TGeoParallelWorld * fParallelWorld
void RegisterMatrix(const TGeoMatrix *matrix)
Register a matrix to the list of matrices.
TVirtualGeoTrack * GetTrack(Int_t index)
static Int_t GetMaxDaughters()
Return maximum number of daughters of a volume used in the geometry.
static void ClearThreadsMap()
Clear the current map of threads.
Int_t AddVolume(TGeoVolume *volume)
Add a volume to the list. Returns index of the volume in list.
TVirtualGeoPainter * fPainter
flag that nodes are the selected objects in pad rather than volumes
Definition TGeoManager.h:92
void SetVolumeAttribute(const char *name, const char *att, Int_t val)
Set volume attributes in G3 style.
const char * GetPdgName(Int_t pdg) const
Get name for given pdg code;.
void CheckGeometryFull(Int_t ntracks=1000000, Double_t vx=0., Double_t vy=0., Double_t vz=0., Option_t *option="ob")
Geometry checking.
Bool_t fIsNodeSelectable
switch ON/OFF volume activity (default OFF - all volumes active))
Definition TGeoManager.h:91
TGeoNode * Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)
Make a rectilinear step of length fStep from current point (fPoint) on current direction (fDirection)...
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
Bool_t fActivity
flag for GL reflections
Definition TGeoManager.h:90
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
static ThreadsMap_t * fgThreadId
Map between thread id's and navigator arrays.
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TVirtualGeoTrack * MakeTrack(Int_t id, Int_t pdgcode, TObject *particle)
Makes a primary track but do not attach it to the list of tracks.
Int_t GetTrackIndex(Int_t id) const
Get index for track id, -1 if not found.
Int_t fNNodes
upper time limit for tracks drawing
Definition TGeoManager.h:67
Int_t fNLevel
table of elements
void OptimizeVoxels(const char *filename="tgeovox.C")
Optimize voxelization type for all volumes. Save best choice in a macro.
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
void SetAnimateTracks(Bool_t flag=kTRUE)
Bool_t fIsGeomCleaning
flag set when reading geometry
Definition TGeoManager.h:84
Bool_t IsSameLocation() const
void DefaultColors()
Set default volume colors according to A of material.
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
TGeoVolume * MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz)
Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
Double_t * FindNormal(Bool_t forward=kTRUE)
Computes normal vector to the next surface that will be or was already crossed when propagating on a ...
virtual Int_t GetByteCount(Option_t *option=nullptr)
Get total size of geometry in bytes.
TGeoVolume * MakeGtra(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a twisted trapezoid shape with given medium.
TGeoElementTable * fElementTable
clipping shape for raytracing
static void SetNavigatorsLock(Bool_t flag)
Set the lock for navigators.
static Int_t fgMaxXtruVert
Maximum number of daughters.
Definition TGeoManager.h:55
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
Int_t GetVisOption() const
Returns current depth to which geometry is drawn.
static void LockGeometry()
Lock current geometry so that no other geometry can be imported.
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)
Test for shape navigation methods.
static Int_t fgMaxLevel
Verbosity level for Info messages (no IO).
Definition TGeoManager.h:53
Int_t fNpdg
current track
Definition TGeoManager.h:78
void PrintOverlaps() const
Prints the current list of overlaps.
TGeoVolume * MakeTrd1(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy, Double_t dz)
Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
TGeoVolume * MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin=0, Double_t themax=180, Double_t phimin=0, Double_t phimax=360)
Make in one step a volume pointing to a sphere shape with given medium.
void ResetUserData()
Sets all pointers TGeoVolume::fField to NULL.
TGeoVolume * FindVolumeFast(const char *name, Bool_t multi=kFALSE)
Fast search for a named volume. All trailing blanks stripped.
TList * fMedia
Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const
Get time cut for drawing tracks.
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
ThreadsMap_t::const_iterator ThreadsMapIt_t
Bool_t fMatrixTransform
flag that the list of physical nodes has to be drawn
Definition TGeoManager.h:88
void SetVisibility(TObject *obj, Bool_t vis)
Set visibility for a volume.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Bool_t fMatrixReflection
flag for using GL matrix
Definition TGeoManager.h:89
TGeoPNEntry * SetAlignableEntry(const char *unique_name, const char *path, Int_t uid=-1)
Creates an alignable object with unique name corresponding to a path and adds it to the list of align...
void ClearShape(const TGeoShape *shape)
Remove a shape from the list of shapes.
void ModifiedPad() const
Send "Modified" signal to painter.
void BombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new 'bombed' translation vector according current exploded view mode.
TGeoNavigator * fCurrentNavigator
Lock existing navigators.
static Bool_t LockDefaultUnits(Bool_t new_value)
Int_t fMaxVisNodes
Definition TGeoManager.h:76
TGeoMedium * GetMedium(const char *medium) const
Search for a named tracking medium. All trailing blanks stripped.
Bool_t InsertPNEId(Int_t uid, Int_t ientry)
Insert a PN entry in the sorted array of indexes.
Int_t fVisLevel
Definition TGeoManager.h:73
void ViewLeaves(Bool_t flag=kTRUE)
Set visualization option (leaves only OR all volumes)
TGeoVolume * MakeCtub(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
Make in one step a volume pointing to a tube segment shape with given medium.
void SetTminTmax(Double_t tmin=0, Double_t tmax=999)
Set time cut interval for drawing tracks.
NavigatorsMap_t fNavigators
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
Bool_t fPhiCut
flag to notify that the manager is being destructed
Definition TGeoManager.h:85
TGeoNode * CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode)
Cross next boundary and locate within current node The current point must be on the boundary of fCurr...
void DrawTracks(Option_t *option="")
Draw tracks over the geometry, according to option.
void Streamer(TBuffer &) override
Stream an object of class TGeoManager.
void BuildDefaultMaterials()
Now just a shortcut for GetElementTable.
void SetMaxThreads(Int_t nthreads)
Set maximum number of threads for navigation.
TGeoMedium * Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
Create tracking medium.
void SetExplodedView(Int_t iopt=0)
Set type of exploding view (see TGeoPainter::SetExplodedView())
Double_t Weight(Double_t precision=0.01, Option_t *option="va")
Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
void ClearPhysicalNodes(Bool_t mustdelete=kFALSE)
Clear the current list of physical nodes, so that we can start over with a new list.
static Int_t Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
Parse a string boolean expression and do a syntax check.
void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
Retrieve cartesian and radial bomb factors.
Double_t GetProperty(const char *name, Bool_t *error=nullptr) const
Get a user-defined property.
TObjArray * fTracks
list of runtime volumes
Bool_t IsAnimatingTracks() const
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
static Int_t fgNumThreads
Thread id's map.
TObjArray * fGDMLMatrices
TGeoPhysicalNode * MakeAlignablePN(const char *name)
Make a physical node from the path pointed by an alignable object with a given name.
void SetCheckedNode(TGeoNode *node)
Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
Int_t AddOverlap(const TNamed *ovlp)
Add an illegal overlap/extrusion to the list.
void CreateThreadData() const
Create thread private data for all geometry objects.
Int_t fNsegments
Definition TGeoManager.h:74
TObjArray * fOverlaps
TGeoNode * SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil=1E-5, const char *g3path="")
shoot npoints randomly in a box of 1E-5 around current point.
Bool_t IsMultiThread() const
TGDMLMatrix * GetGDMLMatrix(const char *name) const
Get GDML matrix with a given name;.
Double_t fTmax
lower time limit for tracks drawing
Definition TGeoManager.h:66
Int_t TransformVolumeToAssembly(const char *vname)
Transform all volumes named VNAME to assemblies. The volumes must be virtual.
Bool_t fMultiThread
Max number of threads.
TGeoVolume * MakePgon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
Make in one step a volume pointing to a polygone shape with given medium.
TGeoVolume * MakeTrap(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a trapezoid shape with given medium.
void DrawCurrentPoint(Int_t color=2)
Draw current point in the same view.
static void SetVerboseLevel(Int_t vl)
Return current verbosity level (static function).
TGeoOpticalSurface * GetOpticalSurface(const char *name) const
Get optical surface with a given name;.
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
static UInt_t GetExportPrecision()
Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const
Check if a new point with given coordinates is the same as the last located one.
void SetNmeshPoints(Int_t npoints=1000)
Set the number of points to be generated on the shape outline when checking for overlaps.
void CheckBoundaryReference(Int_t icheck=-1)
Check the boundary errors reference file created by CheckBoundaryErrors method.
static Int_t GetVerboseLevel()
Set verbosity level (static function).
Int_t GetVisLevel() const
Returns current depth to which geometry is drawn.
static EDefaultUnits fgDefaultUnits
Precision to be used in ASCII exports.
Definition TGeoManager.h:57
virtual void Edit(Option_t *option="")
Append a pad for this geometry.
Bool_t AddProperty(const char *property, Double_t value)
Add a user-defined property. Returns true if added, false if existing.
~TGeoManager() override
Destructor.
TObjArray * fNodes
Int_t CountNodes(const TGeoVolume *vol=nullptr, Int_t nlevels=10000, Int_t option=0)
Count the total number of nodes starting from a volume, nlevels down.
TGeoMaterial * GetMaterial(const char *matname) const
Search for a named material. All trailing blanks stripped.
void CheckGeometry(Option_t *option="")
Perform last checks on the geometry.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute mouse actions on this manager.
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
Make an assembly of volumes.
Int_t GetBombMode() const
Int_t AddRegion(TGeoRegion *region)
Add a new region of volumes.
void SelectTrackingMedia()
Define different tracking media.
void CdNext()
Do a cd to the node found next by FindNextBoundary.
void CdTop()
Make top level node the current node.
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
Int_t * fKeyPNEId
void DefaultAngles()
Set default angles for a given view.
TGeoMaterial * Mixture(const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nelem, Float_t *wmat, Int_t uid)
Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem materials defined by arrays A,...
std::map< std::thread::id, Int_t > ThreadsMap_t
void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="", Double_t safety=0.)
Classify a given point. See TGeoChecker::CheckPoint().
void SetUseParallelWorldNav(Bool_t flag)
Activate/deactivate usage of parallel world navigation.
void Browse(TBrowser *b) override
Describe how to browse this object.
void Test(Int_t npoints=1000000, Option_t *option="")
Check time of finding "Where am I" for n points.
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
TObjArray * fGVolumes
list of runtime shapes
void SetBombFactors(Double_t bombx=1.3, Double_t bomby=1.3, Double_t bombz=1.3, Double_t bombr=1.3)
Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
TGeoNode * fTopNode
top level volume in geometry
void UnbombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new 'unbombed' translation vector according current exploded view mode.
void ResetState()
Reset current state flags.
void RandomPoints(const TGeoVolume *vol, Int_t npoints=10000, Option_t *option="")
Draw random points in the bounding box of a volume.
TGeoParallelWorld * CreateParallelWorld(const char *name)
Create a parallel world for prioritised navigation.
Int_t GetMaterialIndex(const char *matname) const
Return index of named material.
void CdDown(Int_t index)
Make a daughter of current node current.
TGeoNavigatorArray * GetListOfNavigators() const
Get list of navigators for the calling thread.
static Int_t GetMaxXtruVert()
Return maximum number of vertices for an xtru shape used.
void RandomRays(Int_t nrays=1000, Double_t startx=0, Double_t starty=0, Double_t startz=0, const char *target_vol=nullptr, Bool_t check_norm=kFALSE)
Randomly shoot nrays and plot intersections with surfaces for current top node.
void SetAllIndex()
Assigns uid's for all materials,media and matrices.
TObjArray * fSkinSurfaces
void SetVisDensity(Double_t dens=0.01)
Set density threshold.
Int_t fExplodedView
Definition TGeoManager.h:71
Bool_t fClosed
Definition TGeoManager.h:80
Int_t GetNsegments() const
Get number of segments approximating circles.
void SetPhiRange(Double_t phimin=0., Double_t phimax=360.)
Set cut phi range.
TGeoHMatrix * fGLMatrix
TVirtualGeoTrack * fCurrentTrack
Definition TGeoManager.h:77
TObjArray * fPdgNames
void DrawPath(const char *path, Option_t *option="")
Draw current path.
TObjArray * GetListOfPhysicalNodes()
static Int_t ThreadId()
Translates the current thread id to an ordinal number.
Bool_t SetCurrentNavigator(Int_t index)
Switch to another existing navigator for the calling thread.
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
TGeoVolume * MakeHype(const char *name, TGeoMedium *medium, Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeParaboloid(const char *name, TGeoMedium *medium, Double_t rlo, Double_t rhi, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
Int_t AddShape(const TGeoShape *shape)
Add a shape to the list. Returns index of the shape in list.
void SetMaxVisNodes(Int_t maxnodes=10000)
set the maximum number of visible nodes.
void CleanGarbage()
Clean temporary volumes and shapes from garbage collection.
void Voxelize(Option_t *option=nullptr)
Voxelize all non-divided volumes.
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
TGeoBorderSurface * GetBorderSurface(const char *name) const
Get border surface with a given name;.
void ClearThreadData() const
Int_t fSizePNEId
array of physical node entries
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check all geometry for illegal overlaps within a limit OVLP.
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
Int_t fPdgId[1024]
Definition TGeoManager.h:79
void SortOverlaps()
Sort overlaps by decreasing overlap distance. Extrusions comes first.
TGeoVolume * MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
void RemoveNavigator(const TGeoNavigator *nav)
Clear a single navigator.
void MasterToTop(const Double_t *master, Double_t *top) const
Convert coordinates from master volume frame to top.
Bool_t fStreamVoxels
flag volume lists loop
Definition TGeoManager.h:82
Base class describing materials.
Geometrical transformation package.
Definition TGeoMatrix.h:38
@ kGeoSavePrimitive
Definition TGeoMatrix.h:48
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
@ kMedSavePrimitive
Definition TGeoMedium.h:25
Mixtures of elements.
Int_t GetNelements() const override
TGeoElement * GetElement(Int_t i=0) const override
Retrieve the pointer to the element corresponding to component I.
TGeoNavigator * AddNavigator()
Add a new navigator to the array.
TGeoNavigator * GetCurrentNavigator() const
TGeoNavigator * SetCurrentNavigator(Int_t inav)
Class providing navigation API for TGeo geometries.
void CdUp()
Go one level up in geometry.
void DoBackupState()
Backup the current state without affecting the cache stack.
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
TGeoNode * CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode)
Cross next boundary and locate within current node The current point must be on the boundary of fCurr...
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
void LocalToMaster(const Double_t *local, Double_t *master) const
void CdNext()
Do a cd to the node found next by FindNextBoundary.
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
Bool_t cd(const char *path="")
Browse the tree of nodes starting from top node according to pathname.
Bool_t IsSameLocation(Double_t x, Double_t y, Double_t z, Bool_t change=kFALSE)
Checks if point (x,y,z) is still in the current node.
void MasterToLocal(const Double_t *master, Double_t *local) const
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
void InspectState() const
Inspects path and all flags for the current state.
TGeoNode * Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)
Make a rectiliniar step of length fStep from current point (fPoint) on current direction (fDirection)...
TGeoVolume * GetCurrentVolume() const
void ResetState()
Reset current state flags.
TGeoNode * FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE)
Computes as fStep the distance to next daughter of the current volume.
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
Bool_t CheckPath(const char *path) const
Check if a geometry path is valid without changing the state of the navigator.
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
void CdTop()
Make top level node the current node.
Int_t GetCurrentNodeId() const
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
void GetBranchOnlys(Int_t *isonly) const
Fill node copy numbers of current branch into an array.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=nullptr)
Returns the deepest node containing fPoint, which must be set a priori.
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const
Check if a new point with given coordinates is the same as the last located one.
void CdDown(Int_t index)
Make a daughter of current node current.
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
Double_t * FindNormal(Bool_t forward=kTRUE)
Computes normal vector to the next surface that will be or was already crossed when propagating on a ...
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
A node containing local transformation.
Definition TGeoNode.h:154
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
Bool_t IsOverlapping() const
Definition TGeoNode.h:107
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
void SaveAttributes(std::ostream &out)
save attributes for this node
Definition TGeoNode.cxx:439
void SetVolume(TGeoVolume *volume)
Definition TGeoNode.h:117
void CheckShapes()
check for wrong parameters in shapes
Definition TGeoNode.cxx:329
void SetOverlapping(Bool_t flag=kTRUE)
Definition TGeoNode.h:120
Int_t GetNdaughters() const
Definition TGeoNode.h:91
virtual TGeoMatrix * GetMatrix() const =0
void SetVisibility(Bool_t vis=kTRUE) override
Set visibility of the node (obsolete).
Definition TGeoNode.cxx:718
void SetMotherVolume(TGeoVolume *mother)
Definition TGeoNode.h:125
static TClass * Class()
TGeoVolume * GetMotherVolume() const
Definition TGeoNode.h:90
void SetNumber(Int_t number)
Definition TGeoNode.h:118
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition TGeoNode.cxx:192
This is a wrapper class to G4OpticalSurface.
The knowledge of the path to the objects that need to be misaligned is essential since there is no ot...
Base class for a flat parallel geometry.
Bool_t CloseGeometry()
The main geometry must be closed.
void RefreshPhysicalNodes()
Refresh the node pointers and re-voxelize.
Bool_t IsClosed() const
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
Regions are groups of volumes having a common set of user tracking cuts.
Definition TGeoRegion.h:36
Base abstract class for all shapes.
Definition TGeoShape.h:25
virtual Bool_t IsComposite() const
Definition TGeoShape.h:138
Bool_t IsRunTimeShape() const
Definition TGeoShape.h:150
virtual void ComputeBBox()=0
virtual void AfterStreamer()
Definition TGeoShape.h:100
@ kGeoClosedShape
Definition TGeoShape.h:59
TClass * IsA() const override
Definition TGeoShape.h:179
Bool_t TestShapeBit(UInt_t f) const
Definition TGeoShape.h:175
Volume assemblies.
Definition TGeoVolume.h:316
static TGeoVolumeAssembly * MakeAssemblyFromVolume(TGeoVolume *vol)
Make a clone of volume VOL but which is an assembly.
Volume families.
Definition TGeoVolume.h:266
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
Double_t WeightA() const
Analytical computation of the weight.
virtual void ClearThreadData() const
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
void SetNumber(Int_t number)
Definition TGeoVolume.h:245
void SetLineWidth(Width_t lwidth) override
Set the line width.
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:175
Int_t GetRefCount() const
Definition TGeoVolume.h:131
void SortNodes()
sort nodes by decreasing volume of the bounding box.
void Voxelize(Option_t *option)
build the voxels for this volume
Bool_t IsRunTime() const
Definition TGeoVolume.h:109
virtual void CreateThreadData(Int_t nthreads)
virtual Int_t GetByteCount() const
get the total size in bytes for this volume
Bool_t OptimizeVoxels()
Perform an extensive sampling to find which type of voxelization is most efficient.
virtual Bool_t IsVolumeMulti() const
Definition TGeoVolume.h:110
Int_t CountNodes(Int_t nlevels=1000, Int_t option=0)
Count total number of subnodes starting from this volume, nlevels down.
void UnmarkSaved()
Reset SavePrimitive bits.
void SetFinder(TGeoPatternFinder *finder)
Definition TGeoVolume.h:244
Int_t GetNdaughters() const
Definition TGeoVolume.h:362
void Grab()
Definition TGeoVolume.h:136
static TClass * Class()
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:376
void Release()
Definition TGeoVolume.h:137
void FindOverlaps() const
loop all nodes marked as overlaps and find overlapping brothers
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
virtual void SetMedium(TGeoMedium *medium)
Definition TGeoVolume.h:242
TGeoVoxelFinder * GetVoxels() const
Getter for optimization structure.
static TGeoMedium * DummyMedium()
void SetLineColor(Color_t lcolor) override
Set the line color.
Int_t GetNumber() const
Definition TGeoVolume.h:184
TGeoShape * GetShape() const
Definition TGeoVolume.h:190
void SaveAs(const char *filename="", Option_t *option="") const override
Save geometry having this as top volume as a C++ macro.
void SetField(TObject *field)
Definition TGeoVolume.h:231
static void CreateDummyMedium()
Create a dummy medium.
void SetLineStyle(Style_t lstyle) override
Set the line style.
virtual Bool_t IsAssembly() const
Returns true if the volume is an assembly or a scaled assembly.
TGeoVolume * MakeReflectedVolume(const char *newname="") const
Make a copy of this volume which is reflected with respect to XY plane.
virtual Bool_t IsVisible() const
Definition TGeoVolume.h:155
Finder class handling voxels.
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
Definition TGeoXtru.h:22
static TClass * Class()
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
void Clear(Option_t *option="") override
Remove all objects from the list.
TObject * FindObject(const char *name) const override
Find object using its name.
void AddLast(TObject *obj) override
Add object at the end of the list.
Definition THashList.cxx: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:575
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:467
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:354
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:164
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:84
TObject * Remove(TObject *obj) override
Remove object from array.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Add(TObject *obj) override
Definition TObjArray.h:68
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:421
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition TObject.cxx:964
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1099
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:875
virtual TClass * IsA() const
Definition TObject.h:246
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1045
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:640
Abstract class for geometry checkers.
virtual void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="", Double_t safety=0.)=0
virtual void CheckGeometryFull(Bool_t checkoverlaps=kTRUE, Bool_t checkcrossings=kTRUE, Int_t nrays=10000, const Double_t *vertex=nullptr)=0
virtual void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)=0
virtual void RandomPoints(TGeoVolume *vol, Int_t npoints, Option_t *option)=0
virtual void Test(Int_t npoints, Option_t *option)=0
virtual void CheckBoundaryReference(Int_t icheck=-1)=0
virtual Double_t Weight(Double_t precision=0.01, Option_t *option="v")=0
virtual void SetNmeshPoints(Int_t npoints=1000)=0
virtual void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)=0
virtual TGeoNode * SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil, const char *g3path)=0
virtual void SetSelectedNode(TGeoNode *node)=0
virtual void TestOverlaps(const char *path)=0
virtual void RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol=nullptr, Bool_t check_norm=kFALSE)=0
Abstract class for geometry painters.
virtual void SetTopVisible(Bool_t vis=kTRUE)=0
virtual Int_t GetVisLevel() const =0
virtual void DrawPath(const char *path, Option_t *option="")=0
virtual void ModifiedPad(Bool_t update=kFALSE) const =0
virtual void GetViewAngles(Double_t &, Double_t &, Double_t &)
virtual TVirtualGeoTrack * AddTrack(Int_t id, Int_t pdgcode, TObject *particle)=0
virtual void SetExplodedView(Int_t iopt=0)=0
virtual Bool_t IsRaytracing() const =0
virtual void DrawCurrentPoint(Int_t color)=0
virtual void GrabFocus(Int_t nfr=0, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0)=0
virtual void SetVisOption(Int_t option=0)=0
virtual Double_t * GetViewBox()=0
virtual void EstimateCameraMove(Double_t, Double_t, Double_t *, Double_t *)
virtual void SetNsegments(Int_t nseg=20)=0
virtual Int_t CountVisibleNodes()=0
virtual void DefaultAngles()=0
virtual void UnbombTranslation(const Double_t *tr, Double_t *bombtr)=0
virtual void EditGeometry(Option_t *option="")=0
virtual void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const =0
virtual void BombTranslation(const Double_t *tr, Double_t *bombtr)=0
virtual void ExecuteManagerEvent(TGeoManager *geom, Int_t event, Int_t px, Int_t py)=0
virtual void SetBombFactors(Double_t bombx=1.3, Double_t bomby=1.3, Double_t bombz=1.3, Double_t bombr=1.3)=0
Base class for user-defined tracks attached to a geometry.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
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:348
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:75