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 <atomic>
240#include <cstdlib>
241#include <iostream>
242#include <fstream>
243
244#include "TROOT.h"
245#include "TGeoManager.h"
246#include "TStyle.h"
247#include "TVirtualPad.h"
248#include "TBrowser.h"
249#include "TFile.h"
250#include "TKey.h"
251#include "THashList.h"
252#include "TClass.h"
253#include "ThreadLocalStorage.h"
254#include "TBufferText.h"
255
256#include "TGeoVoxelFinder.h"
257#include "TGeoElement.h"
258#include "TGeoMaterial.h"
259#include "TGeoMedium.h"
260#include "TGeoMatrix.h"
261#include "TGeoNode.h"
262#include "TGeoPhysicalNode.h"
263#include "TGeoPara.h"
264#include "TGeoParaboloid.h"
265#include "TGeoTube.h"
266#include "TGeoEltu.h"
267#include "TGeoHype.h"
268#include "TGeoCone.h"
269#include "TGeoSphere.h"
270#include "TGeoArb8.h"
271#include "TGeoPgon.h"
272#include "TGeoTrd1.h"
273#include "TGeoTrd2.h"
274#include "TGeoTorus.h"
275#include "TGeoXtru.h"
276#include "TGeoCompositeShape.h"
277#include "TGeoBoolNode.h"
278#include "TGeoBuilder.h"
279#include "TVirtualGeoPainter.h"
280#include "TVirtualGeoChecker.h"
281#include "TPluginManager.h"
282#include "TVirtualGeoTrack.h"
283#include "TQObject.h"
284#include "TMath.h"
285#include "TEnv.h"
286#include "TGeoParallelWorld.h"
287#include "TGeoRegion.h"
288#include "TGDMLMatrix.h"
289#include "TGeoOpticalSurface.h"
290#include "TGeoColorScheme.h"
291
292// statics and globals
293
295
296std::mutex TGeoManager::fgMutex;
308
309namespace {
310
311struct TGeoManagerThreadState {
312 const TGeoManager *fManager = nullptr;
313 TGeoNavigator *fNavigator = nullptr;
314 ULong64_t fNavigatorGeneration = 0;
315 Int_t fThreadId = -1;
316 ULong64_t fThreadIdGeneration = 0;
317};
318
319TGeoManagerThreadState &GetGeoManagerThreadState()
320{
321 TTHREAD_TLS(TGeoManagerThreadState) state;
322 return state;
323}
324
325// Thread-local navigator pointers and thread ordinals cannot be reset by the thread deleting a manager.
326// Advancing this generation on destructive/global state transitions makes every thread refresh on its next access.
327std::atomic<ULong64_t> gGeoManagerThreadStateGeneration{1};
328
330{
331 gGeoManagerThreadStateGeneration.fetch_add(1, std::memory_order_release);
332}
333
334} // namespace
335
336////////////////////////////////////////////////////////////////////////////////
337/// Default constructor.
338
340{
341 if (!fgThreadId)
345 fTmin = 0.;
346 fTmax = 999.;
347 fPhiCut = kFALSE;
348 fPhimin = 0;
349 fPhimax = 360;
354 fClosed = kFALSE;
356 fBits = nullptr;
357 fCurrentNavigator = nullptr;
358 fMaterials = nullptr;
359 fHashPNE = nullptr;
360 fArrayPNE = nullptr;
361 fMatrices = nullptr;
362 fNodes = nullptr;
363 fOverlaps = nullptr;
364 fRegions = nullptr;
365 fNNodes = 0;
366 fMaxVisNodes = 10000;
367 fVolumes = nullptr;
368 fPhysicalNodes = nullptr;
369 fShapes = nullptr;
370 fGVolumes = nullptr;
371 fGShapes = nullptr;
372 fTracks = nullptr;
373 fMedia = nullptr;
374 fNtracks = 0;
375 fNpdg = 0;
376 fPdgNames = nullptr;
377 fGDMLMatrices = nullptr;
378 fOpticalSurfaces = nullptr;
379 fSkinSurfaces = nullptr;
380 fBorderSurfaces = nullptr;
381 memset(fPdgId, 0, 1024 * sizeof(Int_t));
382 // TObjArray *fNavigators; ///<! list of navigators
383 fCurrentTrack = nullptr;
384 fCurrentVolume = nullptr;
385 fTopVolume = nullptr;
386 fTopNode = nullptr;
387 fMasterVolume = nullptr;
388 fPainter = nullptr;
389 fChecker = nullptr;
392 fVisDensity = 0.;
393 fVisLevel = 3;
394 fVisOption = 1;
395 fExplodedView = 0;
396 fNsegments = 20;
397 fNLevel = 0;
398 fUniqueVolumes = nullptr;
399 fClippingShape = nullptr;
402 fGLMatrix = nullptr;
403 fPaintVolume = nullptr;
404 fUserPaintVolume = nullptr;
405 fElementTable = nullptr;
406 fHashVolumes = nullptr;
407 fHashGVolumes = nullptr;
408 fSizePNEId = 0;
409 fNPNEId = 0;
410 fKeyPNEId = nullptr;
411 fValuePNEId = nullptr;
413 fRaytraceMode = 0;
414 fMaxThreads = 0;
416 fParallelWorld = nullptr;
418 } else {
419 Init();
421 gGeoIdentity = new TGeoIdentity("Identity");
423 }
424}
425
426////////////////////////////////////////////////////////////////////////////////
427/// Constructor.
428
429TGeoManager::TGeoManager(const char *name, const char *title) : TNamed(name, title)
430{
431 if (!gROOT->GetListOfGeometries()->FindObject(this))
432 gROOT->GetListOfGeometries()->Add(this);
433 if (!gROOT->GetListOfBrowsables()->FindObject(this))
434 gROOT->GetListOfBrowsables()->Add(this);
435 Init();
436 gGeoIdentity = new TGeoIdentity("Identity");
438 if (fgVerboseLevel > 0)
439 Info("TGeoManager", "Geometry %s, %s created", GetName(), GetTitle());
440}
441
442////////////////////////////////////////////////////////////////////////////////
443/// Initialize manager class.
444
446{
447 if (gGeoManager) {
448 Warning("Init", "Deleting previous geometry: %s/%s", gGeoManager->GetName(), gGeoManager->GetTitle());
449 delete gGeoManager;
450 if (fgLock)
451 Fatal("Init", "New geometry created while the old one locked !!!");
452 }
453
454 gGeoManager = this;
455 if (!fgThreadId)
458 fTmin = 0.;
459 fTmax = 999.;
460 fPhiCut = kFALSE;
461 fPhimin = 0;
462 fPhimax = 360;
467 fClosed = kFALSE;
469 fBits = new UChar_t[50000]; // max 25000 nodes per volume
470 fCurrentNavigator = nullptr;
471 fHashPNE = new THashList(256, 3);
472 fArrayPNE = nullptr;
473 fMaterials = new THashList(200, 3);
474 fMatrices = new TObjArray(256);
475 fNodes = new TObjArray(30);
476 fOverlaps = new TObjArray(256);
477 fRegions = new TObjArray(256);
478 fNNodes = 0;
479 fMaxVisNodes = 10000;
480 fVolumes = new TObjArray(256);
481 fPhysicalNodes = new TObjArray(256);
482 fShapes = new TObjArray(256);
483 fGVolumes = new TObjArray(256);
484 fGShapes = new TObjArray(256);
485 fTracks = new TObjArray(256);
486 fMedia = new THashList(200, 3);
487 fNtracks = 0;
488 fNpdg = 0;
489 fPdgNames = nullptr;
490 fGDMLMatrices = new TObjArray();
492 fSkinSurfaces = new TObjArray();
494 memset(fPdgId, 0, 1024 * sizeof(Int_t));
495 fCurrentTrack = nullptr;
496 fCurrentVolume = nullptr;
497 fTopVolume = nullptr;
498 fTopNode = nullptr;
499 fMasterVolume = nullptr;
500 fPainter = nullptr;
501 fChecker = nullptr;
504 fVisDensity = 0.;
505 fVisLevel = 3;
506 fVisOption = 1;
507 fExplodedView = 0;
508 fNsegments = 20;
509 fNLevel = 0;
510 fUniqueVolumes = new TObjArray(256);
511 fClippingShape = nullptr;
514 fGLMatrix = new TGeoHMatrix();
515 fPaintVolume = nullptr;
516 fUserPaintVolume = nullptr;
517 fElementTable = nullptr;
518 fHashVolumes = nullptr;
519 fHashGVolumes = nullptr;
520 fSizePNEId = 0;
521 fNPNEId = 0;
522 fKeyPNEId = nullptr;
523 fValuePNEId = nullptr;
525 fRaytraceMode = 0;
526 fMaxThreads = 0;
528 fParallelWorld = nullptr;
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Destructor
534
536{
537 if (gGeoManager != this)
538 gGeoManager = this;
540
541 if (gROOT->GetListOfFiles()) { // in case this function is called from TROOT destructor
542 gROOT->GetListOfGeometries()->Remove(this);
543 gROOT->GetListOfBrowsables()->Remove(this);
544 }
545 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
546 // TIter next(brlist);
547 // TBrowser *browser = 0;
548 // while ((browser=(TBrowser*)next())) browser->RecursiveRemove(this);
551 delete TGeoBuilder::Instance(this);
552 if (fBits)
553 delete[] fBits;
556 if (fOverlaps) {
557 fOverlaps->Delete();
559 }
560 if (fRegions) {
561 fRegions->Delete();
563 }
564 if (fMaterials) {
567 }
569 if (fMedia) {
570 fMedia->Delete();
572 }
573 if (fHashVolumes) {
574 fHashVolumes->Clear("nodelete");
576 }
577 if (fHashGVolumes) {
578 fHashGVolumes->Clear("nodelete");
580 }
581 if (fHashPNE) {
582 fHashPNE->Delete();
584 }
585 if (fArrayPNE) {
586 delete fArrayPNE;
587 }
588 if (fVolumes) {
589 fVolumes->Delete();
591 }
592 if (fShapes) {
593 fShapes->Delete();
595 }
596 if (fPhysicalNodes) {
599 }
600 if (fMatrices) {
601 fMatrices->Delete();
603 }
604 if (fTracks) {
605 fTracks->Delete();
607 }
609 if (fPdgNames) {
610 fPdgNames->Delete();
612 }
613 if (fGDMLMatrices) {
616 }
617 if (fOpticalSurfaces) {
620 }
621 if (fSkinSurfaces) {
624 }
625 if (fBorderSurfaces) {
628 }
630 CleanGarbage();
634 if (fSizePNEId) {
635 delete[] fKeyPNEId;
636 delete[] fValuePNEId;
637 }
638 delete fParallelWorld;
640 gGeoIdentity = nullptr;
641 gGeoManager = nullptr;
642}
643
644////////////////////////////////////////////////////////////////////////////////
645/// Add a material to the list. Returns index of the material in list.
646
648{
649 return TGeoBuilder::Instance(this)->AddMaterial((TGeoMaterial *)material);
650}
651
652////////////////////////////////////////////////////////////////////////////////
653/// Add an illegal overlap/extrusion to the list.
654
661
662////////////////////////////////////////////////////////////////////////////////
663/// Add a new region of volumes.
670
671////////////////////////////////////////////////////////////////////////////////
672/// Add a user-defined property. Returns true if added, false if existing.
673
675{
676 auto pos = fProperties.insert(ConstPropMap_t::value_type(property, value));
677 if (!pos.second) {
678 Warning("AddProperty", "Property \"%s\" already exists with value %g", property, (pos.first)->second);
679 return false;
680 }
681 return true;
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// Get a user-defined property
686
688{
689 auto pos = fProperties.find(property);
690 if (pos == fProperties.end()) {
691 if (error)
692 *error = kTRUE;
693 return 0.;
694 }
695 if (error)
696 *error = kFALSE;
697 return pos->second;
698}
699
700////////////////////////////////////////////////////////////////////////////////
701/// Get a user-defined property from a given index
702
704{
705 // This is a quite inefficient way to access map elements, but needed for the GDML writer to
706 if (i >= fProperties.size()) {
707 if (error)
708 *error = kTRUE;
709 return 0.;
710 }
711 size_t pos = 0;
712 auto it = fProperties.begin();
713 while (pos < i) {
714 ++it;
715 ++pos;
716 }
717 if (error)
718 *error = kFALSE;
719 name = (*it).first;
720 return (*it).second;
721}
722
723////////////////////////////////////////////////////////////////////////////////
724/// Add a matrix to the list. Returns index of the matrix in list.
725
727{
728 return TGeoBuilder::Instance(this)->AddTransformation((TGeoMatrix *)matrix);
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Add a shape to the list. Returns index of the shape in list.
733
735{
736 return TGeoBuilder::Instance(this)->AddShape((TGeoShape *)shape);
737}
738
739////////////////////////////////////////////////////////////////////////////////
740/// Add a track to the list of tracks. Use this for primaries only. For secondaries,
741/// add them to the parent track. The method create objects that are registered
742/// to the analysis manager but have to be cleaned-up by the user via ClearTracks().
743
750
751////////////////////////////////////////////////////////////////////////////////
752/// Add a track to the list of tracks
753
760
761////////////////////////////////////////////////////////////////////////////////
762/// Makes a primary track but do not attach it to the list of tracks. The track
763/// can be attached as daughter to another one with TVirtualGeoTrack::AddTrack
764
770
771////////////////////////////////////////////////////////////////////////////////
772/// Add a volume to the list. Returns index of the volume in list.
773
775{
776 if (!volume) {
777 Error("AddVolume", "invalid volume");
778 return -1;
779 }
781 if (!uid)
782 uid++;
783 if (!fCurrentVolume) {
784 fCurrentVolume = volume;
785 fUniqueVolumes->AddAtAndExpand(volume, uid);
786 } else {
787 if (!strcmp(volume->GetName(), fCurrentVolume->GetName())) {
788 uid = fCurrentVolume->GetNumber();
789 } else {
790 fCurrentVolume = volume;
791 Int_t olduid = GetUID(volume->GetName());
792 if (olduid < 0) {
793 fUniqueVolumes->AddAtAndExpand(volume, uid);
794 } else {
795 uid = olduid;
796 }
797 }
798 }
799 volume->SetNumber(uid);
800 if (!fHashVolumes) {
801 fHashVolumes = new THashList(256, 3);
802 fHashGVolumes = new THashList(256, 3);
803 }
804 TObjArray *list = fVolumes;
805 if (!volume->GetShape() || volume->IsRunTime() || volume->IsVolumeMulti()) {
806 list = fGVolumes;
807 fHashGVolumes->Add(volume);
808 } else {
809 fHashVolumes->Add(volume);
810 }
811 Int_t index = list->GetEntriesFast();
812 list->AddAtAndExpand(volume, index);
813 return uid;
814}
815
816////////////////////////////////////////////////////////////////////////////////
817/// Add a navigator in the list of navigators. If it is the first one make it
818/// current navigator.
819
821{
822 if (fMultiThread) {
824 fgMutex.lock();
825 }
826 std::thread::id threadId = std::this_thread::get_id();
827 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
828 TGeoNavigatorArray *array = nullptr;
829 if (it != fNavigators.end())
830 array = it->second;
831 else {
832 array = new TGeoNavigatorArray(this);
833 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
834 }
835 TGeoNavigator *nav = array->AddNavigator();
836 if (fClosed)
837 nav->GetCache()->BuildInfoBranch();
838 if (fMultiThread) {
839 auto &state = GetGeoManagerThreadState();
840 state.fManager = this;
841 state.fNavigator = nav;
842 state.fNavigatorGeneration = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
843 fgMutex.unlock();
844 }
845 return nav;
846}
847
848////////////////////////////////////////////////////////////////////////////////
849/// Returns current navigator for the calling thread.
850
852{
853 if (!fMultiThread)
854 return fCurrentNavigator;
855 auto &state = GetGeoManagerThreadState();
856 const auto generation = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
857 if (state.fNavigator && state.fManager == this && state.fNavigatorGeneration == generation)
858 return state.fNavigator;
859
860 std::lock_guard<std::mutex> lock(fgMutex);
861 std::thread::id threadId = std::this_thread::get_id();
862 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
863 if (it == fNavigators.end()) {
864 state.fManager = this;
865 state.fNavigator = nullptr;
866 state.fNavigatorGeneration = generation;
867 return nullptr;
868 }
869 TGeoNavigatorArray *array = it->second;
870 state.fManager = this;
871 state.fNavigator = array->GetCurrentNavigator();
872 state.fNavigatorGeneration = generation;
873 return state.fNavigator;
874}
875
876////////////////////////////////////////////////////////////////////////////////
877/// Get list of navigators for the calling thread.
878
880{
881 std::unique_lock<std::mutex> lock(fgMutex, std::defer_lock);
882 if (fMultiThread)
883 lock.lock();
884 std::thread::id threadId = std::this_thread::get_id();
885 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
886 if (it == fNavigators.end())
887 return nullptr;
888 TGeoNavigatorArray *array = it->second;
889 return array;
890}
891
892////////////////////////////////////////////////////////////////////////////////
893/// Switch to another existing navigator for the calling thread.
894
896{
897 std::unique_lock<std::mutex> lock(fgMutex, std::defer_lock);
898 if (fMultiThread)
899 lock.lock();
900 std::thread::id threadId = std::this_thread::get_id();
901 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
902 if (it == fNavigators.end()) {
903 Error("SetCurrentNavigator", "No navigator defined for this thread\n");
904 std::cout << " thread id: " << threadId << std::endl;
905 return kFALSE;
906 }
907 TGeoNavigatorArray *array = it->second;
909 if (!nav) {
910 Error("SetCurrentNavigator", "Navigator %d not existing for this thread\n", index);
911 std::cout << " thread id: " << threadId << std::endl;
912 return kFALSE;
913 }
914 if (fMultiThread) {
915 auto &state = GetGeoManagerThreadState();
916 state.fManager = this;
917 state.fNavigator = nav;
918 state.fNavigatorGeneration = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
919 } else {
921 }
922 return kTRUE;
923}
924
925////////////////////////////////////////////////////////////////////////////////
926/// Set the lock for navigators.
927
932
933////////////////////////////////////////////////////////////////////////////////
934/// Clear all navigators.
935
937{
939 if (fMultiThread)
940 fgMutex.lock();
941 TGeoNavigatorArray *arr = nullptr;
942 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
943 arr = (*it).second;
944 if (arr)
945 delete arr;
946 }
947 fNavigators.clear();
948 if (fMultiThread)
949 fgMutex.unlock();
950}
951
952////////////////////////////////////////////////////////////////////////////////
953/// Clear a single navigator.
954
956{
957 if (fMultiThread)
958 fgMutex.lock();
959 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
960 TGeoNavigatorArray *arr = (*it).second;
961 if (arr) {
962 if ((TGeoNavigator *)arr->Remove((TObject *)nav)) {
964 delete nav;
965 if (!arr->GetEntries())
966 fNavigators.erase(it);
967 if (fMultiThread)
968 fgMutex.unlock();
969 return;
970 }
971 }
972 }
973 Error("Remove navigator", "Navigator %p not found", nav);
974 if (fMultiThread)
975 fgMutex.unlock();
976}
977
978////////////////////////////////////////////////////////////////////////////////
979/// Set maximum number of threads for navigation.
980
982{
983 if (!fClosed) {
984 Error("SetMaxThreads", "Cannot set maximum number of threads before closing the geometry");
985 return;
986 }
987 if (!fMultiThread) {
989 std::thread::id threadId = std::this_thread::get_id();
990 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
991 if (it != fNavigators.end()) {
992 TGeoNavigatorArray *array = it->second;
993 fNavigators.erase(it);
994 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
995 }
996 }
997 if (fMaxThreads) {
1000 }
1002 fMaxThreads = nthreads + 1;
1003 if (fMaxThreads > 0) {
1006 }
1007}
1008
1009////////////////////////////////////////////////////////////////////////////////
1010
1012{
1013 if (!fMaxThreads)
1014 return;
1015 fgMutex.lock();
1016 TIter next(fVolumes);
1017 TGeoVolume *vol;
1018 while ((vol = (TGeoVolume *)next()))
1019 vol->ClearThreadData();
1020 fgMutex.unlock();
1021}
1022
1023////////////////////////////////////////////////////////////////////////////////
1024/// Create thread private data for all geometry objects.
1025
1027{
1028 if (!fMaxThreads)
1029 return;
1030 fgMutex.lock();
1031 TIter next(fVolumes);
1032 TGeoVolume *vol;
1033 while ((vol = (TGeoVolume *)next()))
1035 fgMutex.unlock();
1036}
1037
1038////////////////////////////////////////////////////////////////////////////////
1039/// Clear the current map of threads. This will be filled again by the calling
1040/// threads via ThreadId calls.
1041
1043{
1046 return;
1047 fgMutex.lock();
1048 if (!fgThreadId->empty())
1049 fgThreadId->clear();
1050 fgNumThreads = 0;
1051 fgMutex.unlock();
1052}
1053
1054////////////////////////////////////////////////////////////////////////////////
1055/// Translates the current thread id to an ordinal number. This can be used to
1056/// manage data which is specific for a given thread.
1057
1059{
1060 auto &state = GetGeoManagerThreadState();
1061 const auto generation = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
1062 if (state.fThreadId > -1 && state.fThreadIdGeneration == generation)
1063 return state.fThreadId;
1065 state.fThreadId = 0;
1066 state.fThreadIdGeneration = generation;
1067 return 0;
1068 }
1069 std::thread::id threadId = std::this_thread::get_id();
1070 std::lock_guard<std::mutex> lock(fgMutex);
1072 if (it != fgThreadId->end()) {
1073 state.fThreadId = it->second;
1074 state.fThreadIdGeneration = generation;
1075 return state.fThreadId;
1076 }
1077 (*fgThreadId)[threadId] = fgNumThreads;
1078 state.fThreadId = fgNumThreads++;
1079 state.fThreadIdGeneration = generation;
1080 return state.fThreadId;
1081}
1082
1083////////////////////////////////////////////////////////////////////////////////
1084/// Describe how to browse this object.
1085
1087{
1088 if (!b)
1089 return;
1090 if (fMaterials)
1091 b->Add(fMaterials, "Materials");
1092 if (fMedia)
1093 b->Add(fMedia, "Media");
1094 if (fMatrices)
1095 b->Add(fMatrices, "Local transformations");
1096 if (fOverlaps)
1097 b->Add(fOverlaps, "Illegal overlaps");
1098 if (fTracks)
1099 b->Add(fTracks, "Tracks");
1100 if (fMasterVolume)
1101 b->Add(fMasterVolume, "Master Volume", fMasterVolume->IsVisible());
1102 if (fTopVolume)
1103 b->Add(fTopVolume, "Top Volume", fTopVolume->IsVisible());
1104 if (fTopNode)
1105 b->Add(fTopNode);
1106 TString browserImp(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
1107 TQObject::Connect(browserImp.Data(), "Checked(TObject*,Bool_t)", "TGeoManager", this,
1108 "SetVisibility(TObject*,Bool_t)");
1109}
1110
1111////////////////////////////////////////////////////////////////////////////////
1112/// Append a pad for this geometry.
1113
1119
1120////////////////////////////////////////////////////////////////////////////////
1121/// Set visibility for a volume.
1122
1124{
1125 if (obj->IsA() == TGeoVolume::Class()) {
1126 TGeoVolume *vol = (TGeoVolume *)obj;
1127 vol->SetVisibility(vis);
1128 } else {
1129 if (obj->InheritsFrom(TGeoNode::Class())) {
1130 TGeoNode *node = (TGeoNode *)obj;
1131 node->SetVisibility(vis);
1132 } else
1133 return;
1134 }
1136}
1137
1138////////////////////////////////////////////////////////////////////////////////
1139/// Get the new 'bombed' translation vector according current exploded view mode.
1140
1142{
1143 if (fPainter)
1145 return;
1146}
1147
1148////////////////////////////////////////////////////////////////////////////////
1149/// Get the new 'unbombed' translation vector according current exploded view mode.
1150
1152{
1153 if (fPainter)
1155 return;
1156}
1157
1158////////////////////////////////////////////////////////////////////////////////
1159/// Backup the current state without affecting the cache stack.
1160
1165
1166////////////////////////////////////////////////////////////////////////////////
1167/// Restore a backed-up state without affecting the cache stack.
1168
1173
1174////////////////////////////////////////////////////////////////////////////////
1175/// Register a matrix to the list of matrices. It will be cleaned-up at the
1176/// destruction TGeoManager.
1177
1179{
1180 return TGeoBuilder::Instance(this)->RegisterMatrix((TGeoMatrix *)matrix);
1181}
1182
1183////////////////////////////////////////////////////////////////////////////////
1184/// Replaces all occurrences of VORIG with VNEW in the geometry tree. The volume VORIG
1185/// is not replaced from the list of volumes, but all node referencing it will reference
1186/// VNEW instead. Returns number of occurrences changed.
1187
1189{
1190 Int_t nref = 0;
1191 if (!vorig || !vnew)
1192 return nref;
1193 TGeoMedium *morig = vorig->GetMedium();
1195 if (morig)
1196 checkmed = kTRUE;
1197 TGeoMedium *mnew = vnew->GetMedium();
1198 // Try to limit the damage produced by incorrect usage.
1199 if (!mnew && !vnew->IsAssembly()) {
1200 Error("ReplaceVolume", "Replacement volume %s has no medium and it is not an assembly", vnew->GetName());
1201 return nref;
1202 }
1203 if (mnew && checkmed) {
1204 if (mnew->GetId() != morig->GetId())
1205 Warning("ReplaceVolume", "Replacement volume %s has different medium than original volume %s", vnew->GetName(),
1206 vorig->GetName());
1207 checkmed = kFALSE;
1208 }
1209
1210 // Medium checking now performed only if replacement is an assembly and old volume a real one.
1211 // Check result is dependent on positioning.
1213 Int_t i, j, nd;
1214 Int_t ierr = 0;
1215 TGeoVolume *vol;
1216 TGeoNode *node;
1218 for (i = 0; i < nvol; i++) {
1219 vol = (TGeoVolume *)fVolumes->At(i);
1220 if (!vol)
1221 continue;
1222 if (vol == vorig || vol == vnew)
1223 continue;
1224 nd = vol->GetNdaughters();
1225 for (j = 0; j < nd; j++) {
1226 node = vol->GetNode(j);
1227 if (node->GetVolume() == vorig) {
1228 if (checkmed) {
1229 mnew = node->GetMotherVolume()->GetMedium();
1230 if (mnew && mnew->GetId() != morig->GetId())
1231 ierr++;
1232 }
1233 nref++;
1234 if (node->IsOverlapping()) {
1235 node->SetOverlapping(kFALSE);
1236 Info("ReplaceVolume", "%s replaced with assembly and declared NON-OVERLAPPING!", node->GetName());
1237 }
1238 node->SetVolume(vnew);
1239 voxels = node->GetMotherVolume()->GetVoxels();
1240 if (voxels)
1241 voxels->SetNeedRebuild();
1242 } else {
1243 if (node->GetMotherVolume() == vorig) {
1244 nref++;
1245 node->SetMotherVolume(vnew);
1246 if (node->IsOverlapping()) {
1247 node->SetOverlapping(kFALSE);
1248 Info("ReplaceVolume", "%s inside substitute assembly %s declared NON-OVERLAPPING!", node->GetName(),
1249 vnew->GetName());
1250 }
1251 }
1252 }
1253 }
1254 }
1255 if (ierr)
1256 Warning("ReplaceVolume",
1257 "Volumes should not be replaced with assemblies if they are positioned in containers having a different "
1258 "medium ID.\n %i occurrences for assembly replacing volume %s",
1259 ierr, vorig->GetName());
1260 return nref;
1261}
1262
1263////////////////////////////////////////////////////////////////////////////////
1264/// Rebuild the voxel structures that are flagged as needing rebuild.
1265
1267{
1269 TGeoVolume *vol;
1271 for (Int_t i = 0; i < nvol; i++) {
1272 vol = (TGeoVolume *)fVolumes->At(i);
1273 if (!vol)
1274 continue;
1275 voxels = vol->GetVoxels();
1276 if (voxels && voxels->NeedRebuild()) {
1277 voxels->Voxelize();
1278 vol->FindOverlaps(); // after voxelization, check overlaps again
1279 }
1280 }
1281}
1282
1283////////////////////////////////////////////////////////////////////////////////
1284/// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1285
1287{
1289 if (!toTransform) {
1290 Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1291 return 0;
1292 }
1294 Int_t count = 0;
1296 Bool_t replace = kTRUE;
1298 while (index < indmax) {
1299 if (replace) {
1300 replace = kFALSE;
1302 if (transformed) {
1304 count++;
1305 } else {
1306 if (toTransform->IsAssembly())
1307 Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1308 if (!toTransform->GetNdaughters())
1309 Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform",
1310 toTransform->GetName());
1311 if (toTransform->IsVolumeMulti())
1312 Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1313 }
1314 }
1315 index++;
1316 if (index >= indmax)
1317 return count;
1319 if (!strcmp(toTransform->GetName(), vname))
1320 replace = kTRUE;
1321 }
1322 return count;
1323}
1324
1325////////////////////////////////////////////////////////////////////////////////
1326/// Create a new volume by dividing an existing one (GEANT3 like)
1327///
1328/// Divides MOTHER into NDIV divisions called NAME
1329/// along axis IAXIS starting at coordinate value START
1330/// and having size STEP. The created volumes will have tracking
1331/// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1332/// The behavior of the division operation can be triggered using OPTION :
1333///
1334/// OPTION (case insensitive) :
1335/// - N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1336/// - NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1337/// - S - divide all range with given STEP. NDIV is computed and divisions will be centered
1338/// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1339/// - SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1340
1341TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start,
1343{
1344 return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1345}
1346
1347////////////////////////////////////////////////////////////////////////////////
1348/// Create rotation matrix named 'mat<index>'.
1349///
1350/// - index rotation matrix number
1351/// - theta1 polar angle for axis X
1352/// - phi1 azimuthal angle for axis X
1353/// - theta2 polar angle for axis Y
1354/// - phi2 azimuthal angle for axis Y
1355/// - theta3 polar angle for axis Z
1356/// - phi3 azimuthal angle for axis Z
1357///
1358
1364
1365////////////////////////////////////////////////////////////////////////////////
1366/// Create material with given A, Z and density, having an unique id.
1367
1370{
1371 return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1372}
1373
1374////////////////////////////////////////////////////////////////////////////////
1375/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1376/// materials defined by arrays A,Z and WMAT, having an unique id.
1377
1380{
1381 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1382}
1383
1384////////////////////////////////////////////////////////////////////////////////
1385/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1386/// materials defined by arrays A,Z and WMAT, having an unique id.
1387
1390{
1391 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1392}
1393
1394////////////////////////////////////////////////////////////////////////////////
1395/// Create tracking medium
1396///
1397/// - numed tracking medium number assigned
1398/// - name tracking medium name
1399/// - nmat material number
1400/// - isvol sensitive volume flag
1401/// - ifield magnetic field
1402/// - fieldm max. field value (kilogauss)
1403/// - tmaxfd max. angle due to field (deg/step)
1404/// - stemax max. step allowed
1405/// - deemax max. fraction of energy lost in a step
1406/// - epsil tracking precision (cm)
1407/// - stmin min. step due to continuous processes (cm)
1408///
1409/// - ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1410/// - ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1411/// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1412///
1413
1420
1421////////////////////////////////////////////////////////////////////////////////
1422/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1423/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1424/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1425/// In case npar>0, create the volume to be positioned in mother, according
1426/// its actual parameters (gsposp).
1427/// - NAME Volume name
1428/// - NUMBER Copy number of the volume
1429/// - MOTHER Mother volume name
1430/// - X X coord. of the volume in mother ref. sys.
1431/// - Y Y coord. of the volume in mother ref. sys.
1432/// - Z Z coord. of the volume in mother ref. sys.
1433/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1434/// - ISONLY ONLY/MANY flag
1435
1438{
1439 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1440}
1441
1442////////////////////////////////////////////////////////////////////////////////
1443/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1444/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1445/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1446/// In case npar>0, create the volume to be positioned in mother, according
1447/// its actual parameters (gsposp).
1448/// - NAME Volume name
1449/// - NUMBER Copy number of the volume
1450/// - MOTHER Mother volume name
1451/// - X X coord. of the volume in mother ref. sys.
1452/// - Y Y coord. of the volume in mother ref. sys.
1453/// - Z Z coord. of the volume in mother ref. sys.
1454/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1455/// - ISONLY ONLY/MANY flag
1456
1459{
1460 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1461}
1462
1463////////////////////////////////////////////////////////////////////////////////
1464/// Create a volume in GEANT3 style.
1465/// - NAME Volume name
1466/// - SHAPE Volume type
1467/// - NMED Tracking medium number
1468/// - NPAR Number of shape parameters
1469/// - UPAR Vector containing shape parameters
1470
1471TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar)
1472{
1473 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1474}
1475
1476////////////////////////////////////////////////////////////////////////////////
1477/// Create a volume in GEANT3 style.
1478/// - NAME Volume name
1479/// - SHAPE Volume type
1480/// - NMED Tracking medium number
1481/// - NPAR Number of shape parameters
1482/// - UPAR Vector containing shape parameters
1483
1485{
1486 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1487}
1488
1489////////////////////////////////////////////////////////////////////////////////
1490/// Assigns uid's for all materials,media and matrices.
1491
1493{
1494 Int_t index = 1;
1495 TIter next(fMaterials);
1497 while ((mater = (TGeoMaterial *)next())) {
1498 mater->SetUniqueID(index++);
1500 }
1501 index = 1;
1503 TGeoMedium *med;
1504 while ((med = (TGeoMedium *)next1())) {
1505 med->SetUniqueID(index++);
1507 }
1508 index = 1;
1510 TGeoShape *shape;
1511 while ((shape = (TGeoShape *)next2())) {
1512 shape->SetUniqueID(index++);
1513 if (shape->IsComposite())
1514 ((TGeoCompositeShape *)shape)->GetBoolNode()->RegisterMatrices();
1515 }
1516
1519 while ((matrix = (TGeoMatrix *)next3())) {
1520 matrix->RegisterYourself();
1521 }
1523 index = 1;
1524 while ((matrix = (TGeoMatrix *)next4())) {
1525 matrix->SetUniqueID(index++);
1527 }
1529 TGeoVolume *vol;
1530 while ((vol = (TGeoVolume *)next5()))
1531 vol->UnmarkSaved();
1532}
1533
1534////////////////////////////////////////////////////////////////////////////////
1535/// Reset all attributes to default ones. Default attributes for visualization
1536/// are those defined before closing the geometry.
1537
1539{
1540 if (gPad)
1541 delete gPad;
1542 gPad = nullptr;
1543 SetVisOption(0);
1544 SetVisLevel(3);
1545 SetExplodedView(0);
1547 if (!gStyle)
1548 return;
1549 TIter next(fVolumes);
1550 TGeoVolume *vol = nullptr;
1551 while ((vol = (TGeoVolume *)next())) {
1552 if (!vol->IsVisTouched())
1553 continue;
1554 vol->SetVisTouched(kFALSE);
1555 }
1556}
1557////////////////////////////////////////////////////////////////////////////////
1558/// Closing geometry implies checking the geometry validity, fixing shapes
1559/// with negative parameters (run-time shapes)building the cache manager,
1560/// voxelizing all volumes, counting the total number of physical nodes and
1561/// registering the manager class to the browser.
1562
1564{
1565 if (fClosed) {
1566 Warning("CloseGeometry", "geometry already closed");
1567 return;
1568 }
1569 if (!fMasterVolume) {
1570 Error("CloseGeometry", "you MUST call SetTopVolume() first !");
1571 return;
1572 }
1573 if (!gROOT->GetListOfGeometries()->FindObject(this))
1574 gROOT->GetListOfGeometries()->Add(this);
1575 if (!gROOT->GetListOfBrowsables()->FindObject(this))
1576 gROOT->GetListOfBrowsables()->Add(this);
1577 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1578 // TIter next(brlist);
1579 // TBrowser *browser = 0;
1580 // while ((browser=(TBrowser*)next())) browser->Refresh();
1581 TString opt(option);
1582 opt.ToLower();
1583 // Bool_t dummy = opt.Contains("d");
1584 Bool_t nodeid = opt.Contains("i");
1585 // Create a geometry navigator if not present
1586 TGeoNavigator *nav = nullptr;
1587 Int_t nnavigators = 0;
1588 // Check if the geometry is streamed from file
1589 if (fIsGeomReading) {
1590 if (fgVerboseLevel > 0)
1591 Info("CloseGeometry", "Geometry loaded from file...");
1593 if (!fElementTable)
1595 if (!fTopNode) {
1596 if (!fMasterVolume) {
1597 Error("CloseGeometry", "Master volume not streamed");
1598 return;
1599 }
1601 if (fStreamVoxels && fgVerboseLevel > 0)
1602 Info("CloseGeometry", "Voxelization retrieved from file");
1603 }
1604 // Create a geometry navigator if not present
1605 if (!GetCurrentNavigator())
1608 if (!opt.Contains("nv")) {
1609 Voxelize("ALL");
1610 }
1611 CountLevels();
1612 for (Int_t i = 0; i < nnavigators; i++) {
1614 nav->GetCache()->BuildInfoBranch();
1615 if (nodeid)
1616 nav->GetCache()->BuildIdArray();
1617 }
1618 if (!fHashVolumes) {
1621 fHashVolumes = new THashList(nvol + 1, 3);
1622 fHashGVolumes = new THashList(ngvol + 1, 3);
1623 Int_t i;
1624 for (i = 0; i < ngvol; i++)
1626 for (i = 0; i < nvol; i++)
1628 }
1629 fClosed = kTRUE;
1630 if (fParallelWorld) {
1631 if (fgVerboseLevel > 0)
1632 Info("CloseGeometry", "Recreating parallel world %s ...", fParallelWorld->GetName());
1634 }
1635
1636 if (fgVerboseLevel > 0)
1637 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1638 GetTitle());
1639 if (fgVerboseLevel > 0)
1640 Info("CloseGeometry", "----------------modeler ready----------------");
1641 return;
1642 }
1643
1644 // Create a geometry navigator if not present
1645 if (!GetCurrentNavigator())
1649 CheckGeometry();
1650 if (fgVerboseLevel > 0)
1651 Info("CloseGeometry", "Counting nodes...");
1652 fNNodes = CountNodes();
1653 fNLevel = fMasterVolume->CountNodes(1, 3) + 1;
1654 if (fNLevel < 30)
1655 fNLevel = 100;
1656
1657 // BuildIdArray();
1658 // avoid voxelization if requested to speed up geometry startup
1659 if (!opt.Contains("nv")) {
1660 Voxelize("ALL");
1661 } else {
1662 TGeoVolume *vol;
1663 TIter next(fVolumes);
1664 while ((vol = (TGeoVolume *)next())) {
1665 vol->SortNodes();
1666 }
1667 }
1668 if (fgVerboseLevel > 0)
1669 Info("CloseGeometry", "Building cache...");
1670 CountLevels();
1671 for (Int_t i = 0; i < nnavigators; i++) {
1673 nav->GetCache()->BuildInfoBranch();
1674 if (nodeid)
1675 nav->GetCache()->BuildIdArray();
1676 }
1677 fClosed = kTRUE;
1678 if (fgVerboseLevel > 0) {
1679 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1680 GetTitle());
1681 Info("CloseGeometry", "----------------modeler ready----------------");
1682 }
1683}
1684
1685////////////////////////////////////////////////////////////////////////////////
1686/// Clear the list of overlaps.
1687
1689{
1690 if (fOverlaps) {
1691 fOverlaps->Delete();
1692 delete fOverlaps;
1693 }
1694 fOverlaps = new TObjArray();
1695}
1696
1697////////////////////////////////////////////////////////////////////////////////
1698/// Remove a shape from the list of shapes.
1699
1701{
1702 if (fShapes->FindObject(shape))
1703 fShapes->Remove((TGeoShape *)shape);
1704 delete shape;
1705}
1706
1707////////////////////////////////////////////////////////////////////////////////
1708/// Clean temporary volumes and shapes from garbage collection.
1709
1711{
1712 if (!fGVolumes && !fGShapes)
1713 return;
1714 Int_t i, nentries;
1715 if (fGVolumes) {
1717 TGeoVolume *vol = nullptr;
1718 for (i = 0; i < nentries; i++) {
1719 vol = (TGeoVolume *)fGVolumes->At(i);
1720 if (vol)
1721 vol->SetFinder(nullptr);
1722 }
1723 fGVolumes->Delete();
1724 delete fGVolumes;
1725 fGVolumes = nullptr;
1726 }
1727 if (fGShapes) {
1728 fGShapes->Delete();
1729 delete fGShapes;
1730 fGShapes = nullptr;
1731 }
1732}
1733
1734////////////////////////////////////////////////////////////////////////////////
1735/// Change current path to point to the node having this id.
1736/// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1737
1739{
1740 GetCurrentNavigator()->CdNode(nodeid);
1741}
1742
1743////////////////////////////////////////////////////////////////////////////////
1744/// Get the unique ID of the current node.
1745
1750
1751////////////////////////////////////////////////////////////////////////////////
1752/// Make top level node the current node. Updates the cache accordingly.
1753/// Determine the overlapping state of current node.
1754
1756{
1758}
1759
1760////////////////////////////////////////////////////////////////////////////////
1761/// Go one level up in geometry. Updates cache accordingly.
1762/// Determine the overlapping state of current node.
1763
1765{
1767}
1768
1769////////////////////////////////////////////////////////////////////////////////
1770/// Make a daughter of current node current. Can be called only with a valid
1771/// daughter index (no check). Updates cache accordingly.
1772
1777
1778////////////////////////////////////////////////////////////////////////////////
1779/// Do a cd to the node found next by FindNextBoundary
1780
1782{
1784}
1785
1786////////////////////////////////////////////////////////////////////////////////
1787/// Browse the tree of nodes starting from fTopNode according to pathname.
1788/// Changes the path accordingly.
1789
1790Bool_t TGeoManager::cd(const char *path)
1791{
1792 return GetCurrentNavigator()->cd(path);
1793}
1794
1795////////////////////////////////////////////////////////////////////////////////
1796/// Check if a geometry path is valid without changing the state of the current navigator.
1797
1798Bool_t TGeoManager::CheckPath(const char *path) const
1799{
1800 return GetCurrentNavigator()->CheckPath(path);
1801}
1802
1803////////////////////////////////////////////////////////////////////////////////
1804/// Convert all reflections in geometry to normal rotations + reflected shapes.
1805
1807{
1808 if (!fTopNode)
1809 return;
1810 if (fgVerboseLevel > 0)
1811 Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1813 TGeoNode *node;
1817 while ((node = next())) {
1818 matrix = node->GetMatrix();
1819 if (matrix->IsReflection()) {
1820 // printf("%s before\n", node->GetName());
1821 // matrix->Print();
1823 mclone->RegisterYourself();
1824 // Reflect just the rotation component
1825 mclone->ReflectZ(kFALSE, kTRUE);
1826 nodematrix = (TGeoNodeMatrix *)node;
1827 nodematrix->SetMatrix(mclone);
1828 // printf("%s after\n", node->GetName());
1829 // node->GetMatrix()->Print();
1831 node->SetVolume(reflected);
1832 }
1833 }
1834 if (fgVerboseLevel > 0)
1835 Info("ConvertReflections", "Done");
1836}
1837
1838////////////////////////////////////////////////////////////////////////////////
1839/// Count maximum number of nodes per volume, maximum depth and maximum
1840/// number of xtru vertices.
1841
1843{
1844 if (!fTopNode) {
1845 Error("CountLevels", "Top node not defined.");
1846 return;
1847 }
1850 if (fMasterVolume->GetRefCount() > 1)
1852 if (fgVerboseLevel > 1 && fixrefs)
1853 Info("CountLevels", "Fixing volume reference counts");
1854 TGeoNode *node;
1855 Int_t maxlevel = 1;
1857 Int_t maxvertices = 1;
1858 while ((node = next())) {
1859 if (fixrefs) {
1860 node->GetVolume()->Grab();
1861 for (Int_t ibit = 10; ibit < 14; ibit++) {
1862 node->SetBit(BIT(ibit + 4), node->TestBit(BIT(ibit)));
1863 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1864 }
1865 }
1866 if (node->GetNdaughters() > maxnodes)
1867 maxnodes = node->GetNdaughters();
1868 if (next.GetLevel() > maxlevel)
1869 maxlevel = next.GetLevel();
1870 if (node->GetVolume()->GetShape()->IsA() == TGeoXtru::Class()) {
1871 TGeoXtru *xtru = (TGeoXtru *)node->GetVolume()->GetShape();
1872 if (xtru->GetNvert() > maxvertices)
1873 maxvertices = xtru->GetNvert();
1874 }
1875 }
1879 if (fgVerboseLevel > 0)
1880 Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1881}
1882
1883////////////////////////////////////////////////////////////////////////////////
1884/// Count the total number of nodes starting from a volume, nlevels down.
1885
1887{
1888 TGeoVolume *top;
1889 if (!vol) {
1890 top = fTopVolume;
1891 } else {
1892 top = (TGeoVolume *)vol;
1893 }
1894 Int_t count = top->CountNodes(nlevels, option);
1895 return count;
1896}
1897
1898////////////////////////////////////////////////////////////////////////////////
1899/// Set default angles for a given view.
1900
1902{
1903 if (fPainter)
1905}
1906
1907////////////////////////////////////////////////////////////////////////////////
1908/// Draw current point in the same view.
1909
1911{
1912 if (fPainter)
1913 fPainter->DrawCurrentPoint(color);
1914}
1915
1916////////////////////////////////////////////////////////////////////////////////
1917/// Draw animation of tracks
1918
1920{
1923 if (tmin < 0 || tmin >= tmax || nframes < 1)
1924 return;
1926 box[0] = box[1] = box[2] = 0;
1927 box[3] = box[4] = box[5] = 100;
1928 Double_t dt = (tmax - tmin) / Double_t(nframes);
1929 Double_t delt = 2E-9;
1930 Double_t t = tmin;
1931 Int_t i, j;
1932 TString opt(option);
1933 Bool_t save = kFALSE, geomanim = kFALSE;
1934 TString fname;
1935 if (opt.Contains("/S"))
1936 save = kTRUE;
1937
1938 if (opt.Contains("/G"))
1939 geomanim = kTRUE;
1940 SetTminTmax(0, 0);
1941 DrawTracks(opt.Data());
1942 Double_t start[6] = {0, 0, 0, 0, 0, 0};
1943 Double_t end[6] = {0, 0, 0, 0, 0, 0};
1944 Double_t dd[6] = {0, 0, 0, 0, 0, 0};
1945 Double_t dlat = 0, dlong = 0, dpsi = 0;
1946 if (geomanim) {
1947 fPainter->EstimateCameraMove(tmin + 5 * dt, tmin + 15 * dt, start, end);
1948 for (i = 0; i < 3; i++) {
1949 start[i + 3] = 20 + 1.3 * start[i + 3];
1950 end[i + 3] = 20 + 0.9 * end[i + 3];
1951 }
1952 for (i = 0; i < 6; i++) {
1953 dd[i] = (end[i] - start[i]) / 10.;
1954 }
1955 memcpy(box, start, 6 * sizeof(Double_t));
1957 dlong = (-206 - dlong) / Double_t(nframes);
1958 dlat = (126 - dlat) / Double_t(nframes);
1959 dpsi = (75 - dpsi) / Double_t(nframes);
1961 }
1962
1963 for (i = 0; i < nframes; i++) {
1964 if (t - delt < 0)
1965 SetTminTmax(t - delt, t);
1966 else
1967 gGeoManager->SetTminTmax(t - delt, t);
1968 if (geomanim) {
1969 for (j = 0; j < 6; j++)
1970 box[j] += dd[j];
1972 } else {
1973 ModifiedPad();
1974 }
1975 if (save) {
1976 fname = TString::Format("anim%04d.gif", i);
1977 gPad->Print(fname);
1978 }
1979 t += dt;
1980 }
1982}
1983
1984////////////////////////////////////////////////////////////////////////////////
1985/// Draw tracks over the geometry, according to option. By default, only
1986/// primaries are drawn. See TGeoTrack::Draw() for additional options.
1987
1989{
1991 // SetVisLevel(1);
1992 // SetVisOption(1);
1994 for (Int_t i = 0; i < fNtracks; i++) {
1995 track = GetTrack(i);
1996 if (track)
1997 track->Draw(option);
1998 }
2000 ModifiedPad();
2001}
2002
2003////////////////////////////////////////////////////////////////////////////////
2004/// Draw current path
2005
2006void TGeoManager::DrawPath(const char *path, Option_t *option)
2007{
2008 if (!fTopVolume)
2009 return;
2011 GetGeomPainter()->DrawPath(path, option);
2012}
2013
2014////////////////////////////////////////////////////////////////////////////////
2015/// Draw random points in the bounding box of a volume.
2016
2021
2022////////////////////////////////////////////////////////////////////////////////
2023/// Check time of finding "Where am I" for n points.
2024
2029
2030////////////////////////////////////////////////////////////////////////////////
2031/// Geometry overlap checker based on sampling.
2032
2033void TGeoManager::TestOverlaps(const char *path)
2034{
2036}
2037
2038////////////////////////////////////////////////////////////////////////////////
2039/// Fill volume names of current branch into an array.
2040
2042{
2044}
2045
2046////////////////////////////////////////////////////////////////////////////////
2047/// Get name for given pdg code;
2048
2050{
2051 static char defaultname[5] = {"XXX"};
2052 if (!fPdgNames || !pdg)
2053 return defaultname;
2054 for (Int_t i = 0; i < fNpdg; i++) {
2055 if (fPdgId[i] == pdg)
2056 return fPdgNames->At(i)->GetName();
2057 }
2058 return defaultname;
2059}
2060
2061////////////////////////////////////////////////////////////////////////////////
2062/// Set a name for a particle having a given pdg.
2063
2065{
2066 if (!pdg)
2067 return;
2068 if (!fPdgNames) {
2069 fPdgNames = new TObjArray(1024);
2070 }
2071 if (!strcmp(name, GetPdgName(pdg)))
2072 return;
2073 // store pdg name
2074 if (fNpdg > 1023) {
2075 Warning("SetPdgName", "No more than 256 different pdg codes allowed");
2076 return;
2077 }
2078 fPdgId[fNpdg] = pdg;
2079 TNamed *pdgname = new TNamed(name, "");
2081}
2082
2083////////////////////////////////////////////////////////////////////////////////
2084/// Get GDML matrix with a given name;
2085
2087{
2089}
2090
2091////////////////////////////////////////////////////////////////////////////////
2092/// Add GDML matrix;
2094{
2095 if (GetGDMLMatrix(mat->GetName())) {
2096 Error("AddGDMLMatrix", "Matrix %s already added to manager", mat->GetName());
2097 return;
2098 }
2100}
2101
2102////////////////////////////////////////////////////////////////////////////////
2103/// Get optical surface with a given name;
2104
2109
2110////////////////////////////////////////////////////////////////////////////////
2111/// Add optical surface;
2113{
2114 if (GetOpticalSurface(optsurf->GetName())) {
2115 Error("AddOpticalSurface", "Surface %s already added to manager", optsurf->GetName());
2116 return;
2117 }
2119}
2120
2121////////////////////////////////////////////////////////////////////////////////
2122/// Get skin surface with a given name;
2123
2128
2129////////////////////////////////////////////////////////////////////////////////
2130/// Add skin surface;
2132{
2133 if (GetSkinSurface(surf->GetName())) {
2134 Error("AddSkinSurface", "Surface %s already added to manager", surf->GetName());
2135 return;
2136 }
2138}
2139
2140////////////////////////////////////////////////////////////////////////////////
2141/// Get border surface with a given name;
2142
2147
2148////////////////////////////////////////////////////////////////////////////////
2149/// Add border surface;
2151{
2152 if (GetBorderSurface(surf->GetName())) {
2153 Error("AddBorderSurface", "Surface %s already added to manager", surf->GetName());
2154 return;
2155 }
2157}
2158
2159////////////////////////////////////////////////////////////////////////////////
2160/// Fill node copy numbers of current branch into an array.
2161
2166
2167////////////////////////////////////////////////////////////////////////////////
2168/// Fill node copy numbers of current branch into an array.
2169
2174
2175////////////////////////////////////////////////////////////////////////////////
2176/// Retrieve cartesian and radial bomb factors.
2177
2179{
2180 if (fPainter) {
2182 return;
2183 }
2184 bombx = bomby = bombz = bombr = 1.3;
2185}
2186
2187////////////////////////////////////////////////////////////////////////////////
2188/// Return maximum number of daughters of a volume used in the geometry.
2189
2194
2195////////////////////////////////////////////////////////////////////////////////
2196/// Return maximum number of levels used in the geometry.
2197
2199{
2200 return fgMaxLevel;
2201}
2202
2203////////////////////////////////////////////////////////////////////////////////
2204/// Return maximum number of vertices for an xtru shape used.
2205
2210
2211////////////////////////////////////////////////////////////////////////////////
2212/// Returns number of threads that were set to use geometry.
2213
2218
2219////////////////////////////////////////////////////////////////////////////////
2220/// Return stored current matrix (global matrix of the next touched node).
2221
2223{
2224 if (!GetCurrentNavigator())
2225 return nullptr;
2226 return GetCurrentNavigator()->GetHMatrix();
2227}
2228
2229////////////////////////////////////////////////////////////////////////////////
2230/// Returns current depth to which geometry is drawn.
2231
2233{
2234 return fVisLevel;
2235}
2236
2237////////////////////////////////////////////////////////////////////////////////
2238/// Returns current depth to which geometry is drawn.
2239
2241{
2242 return fVisOption;
2243}
2244
2245////////////////////////////////////////////////////////////////////////////////
2246/// Find level of virtuality of current overlapping node (number of levels
2247/// up having the same tracking media.
2248
2253
2254////////////////////////////////////////////////////////////////////////////////
2255/// Search the track hierarchy to find the track with the
2256/// given id
2257///
2258/// if 'primsFirst' is true, then:
2259/// first tries TGeoManager::GetTrackOfId, then does a
2260/// recursive search if that fails. this would be faster
2261/// if the track is somehow known to be a primary
2262
2264{
2265 TVirtualGeoTrack *trk = nullptr;
2266 trk = GetTrackOfId(id);
2267 if (trk)
2268 return trk;
2269 // need recursive search
2270 TIter next(fTracks);
2272 while ((prim = (TVirtualGeoTrack *)next())) {
2273 trk = prim->FindTrackWithId(id);
2274 if (trk)
2275 return trk;
2276 }
2277 return nullptr;
2278}
2279
2280////////////////////////////////////////////////////////////////////////////////
2281/// Get track with a given ID.
2282
2284{
2286 for (Int_t i = 0; i < fNtracks; i++) {
2287 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2288 if (track->GetId() == id)
2289 return track;
2290 }
2291 }
2292 return nullptr;
2293}
2294
2295////////////////////////////////////////////////////////////////////////////////
2296/// Get parent track with a given ID.
2297
2299{
2301 while ((track = track->GetMother())) {
2302 if (track->GetId() == id)
2303 return track;
2304 }
2305 return nullptr;
2306}
2307
2308////////////////////////////////////////////////////////////////////////////////
2309/// Get index for track id, -1 if not found.
2310
2312{
2314 for (Int_t i = 0; i < fNtracks; i++) {
2315 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2316 if (track->GetId() == id)
2317 return i;
2318 }
2319 }
2320 return -1;
2321}
2322
2323////////////////////////////////////////////////////////////////////////////////
2324/// Go upwards the tree until a non-overlapping node
2325
2330
2331////////////////////////////////////////////////////////////////////////////////
2332/// Go upwards the tree until a non-overlapping node
2333
2338
2339////////////////////////////////////////////////////////////////////////////////
2340/// Set default volume colors according to A of material
2341///
2342/// If called with no argument, it uses the new default "natural" scheme
2343/// (including name-based material overrides) and falls back to Z-binned colors.
2344
2346{
2348 const TGeoColorScheme *scheme = cs ? cs : &defaultCS;
2349
2350 TGeoVolume *vol = nullptr;
2351 TIter next(fVolumes);
2352
2353 while ((vol = (TGeoVolume *)next())) {
2354 // Ask scheme for a color (>=0 means "use it")
2355 const Int_t c = scheme->Color(vol);
2356 if (c >= 0)
2357 vol->SetLineColor(c);
2358
2359 // Ask scheme for transparency ([0..100] means "use it")
2360 const Int_t t = scheme->Transparency(vol);
2361 if (t >= 0)
2362 vol->SetTransparency(t);
2363 }
2364 ModifiedPad();
2365}
2366
2367////////////////////////////////////////////////////////////////////////////////
2368/// Compute safe distance from the current point. This represent the distance
2369/// from POINT to the closest boundary.
2370
2372{
2373 return GetCurrentNavigator()->Safety(inside);
2374}
2375
2376////////////////////////////////////////////////////////////////////////////////
2377/// Set volume attributes in G3 style.
2378
2379void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2380{
2381 TGeoVolume *volume;
2382 Bool_t all = kFALSE;
2383 if (strstr(name, "*"))
2384 all = kTRUE;
2385 Int_t ivo = 0;
2386 TIter next(fVolumes);
2387 TString chatt = att;
2388 chatt.ToLower();
2389 while ((volume = (TGeoVolume *)next())) {
2390 if (strcmp(volume->GetName(), name) && !all)
2391 continue;
2392 ivo++;
2393 if (chatt.Contains("colo"))
2394 volume->SetLineColor(val);
2395 if (chatt.Contains("lsty"))
2396 volume->SetLineStyle(val);
2397 if (chatt.Contains("lwid"))
2398 volume->SetLineWidth(val);
2399 if (chatt.Contains("fill"))
2400 volume->SetFillColor(val);
2401 if (chatt.Contains("seen"))
2402 volume->SetVisibility(val);
2403 }
2405 while ((volume = (TGeoVolume *)next1())) {
2406 if (strcmp(volume->GetName(), name) && !all)
2407 continue;
2408 ivo++;
2409 if (chatt.Contains("colo"))
2410 volume->SetLineColor(val);
2411 if (chatt.Contains("lsty"))
2412 volume->SetLineStyle(val);
2413 if (chatt.Contains("lwid"))
2414 volume->SetLineWidth(val);
2415 if (chatt.Contains("fill"))
2416 volume->SetFillColor(val);
2417 if (chatt.Contains("seen"))
2418 volume->SetVisibility(val);
2419 }
2420 if (!ivo) {
2421 Warning("SetVolumeAttribute", "volume: %s does not exist", name);
2422 }
2423}
2424
2425////////////////////////////////////////////////////////////////////////////////
2426/// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2427
2433
2434////////////////////////////////////////////////////////////////////////////////
2435/// Set a user-defined shape as clipping for ray tracing.
2436
2438{
2440 if (shape) {
2441 if (fClippingShape && (fClippingShape != shape))
2443 fClippingShape = shape;
2444 }
2445 painter->SetClippingShape(shape);
2446}
2447
2448////////////////////////////////////////////////////////////////////////////////
2449/// set the maximum number of visible nodes.
2450
2452{
2454 if (maxnodes > 0 && fgVerboseLevel > 0)
2455 Info("SetMaxVisNodes", "Automatic visible depth for %d visible nodes", maxnodes);
2456 if (!fPainter)
2457 return;
2459 Int_t level = fPainter->GetVisLevel();
2460 if (level != fVisLevel)
2461 fVisLevel = level;
2462}
2463
2464////////////////////////////////////////////////////////////////////////////////
2465/// make top volume visible on screen
2466
2472
2473////////////////////////////////////////////////////////////////////////////////
2474/// Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
2475
2480
2481////////////////////////////////////////////////////////////////////////////////
2482/// Set the number of points to be generated on the shape outline when checking
2483/// for overlaps.
2484
2489
2490////////////////////////////////////////////////////////////////////////////////
2491/// set drawing mode :
2492/// - option=0 (default) all nodes drawn down to vislevel
2493/// - option=1 leaves and nodes at vislevel drawn
2494/// - option=2 path is drawn
2495/// - option=4 visibility changed
2496
2498{
2499 if ((option >= 0) && (option < 3))
2501 if (fPainter)
2503}
2504
2505////////////////////////////////////////////////////////////////////////////////
2506/// Set visualization option (leaves only OR all volumes)
2507
2509{
2510 if (flag)
2511 SetVisOption(1);
2512 else
2513 SetVisOption(0);
2514}
2515
2516////////////////////////////////////////////////////////////////////////////////
2517/// Set density threshold. Volumes with densities lower than this become
2518/// transparent.
2519
2526
2527////////////////////////////////////////////////////////////////////////////////
2528/// set default level down to which visualization is performed
2529
2531{
2532 if (level > 0) {
2533 fVisLevel = level;
2534 fMaxVisNodes = 0;
2535 if (fgVerboseLevel > 0)
2536 Info("SetVisLevel", "Automatic visible depth disabled");
2537 if (fPainter)
2539 } else {
2541 }
2542}
2543
2544////////////////////////////////////////////////////////////////////////////////
2545/// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2546
2548{
2549 fOverlaps->Sort();
2550}
2551
2552////////////////////////////////////////////////////////////////////////////////
2553/// Optimize voxelization type for all volumes. Save best choice in a macro.
2554
2556{
2557 if (!fTopNode) {
2558 Error("OptimizeVoxels", "Geometry must be closed first");
2559 return;
2560 }
2561 std::ofstream out;
2563 if (fname.IsNull())
2564 fname = "tgeovox.C";
2565 out.open(fname, std::ios::out);
2566 if (!out.good()) {
2567 Error("OptimizeVoxels", "cannot open file");
2568 return;
2569 }
2570 // write header
2571 TDatime t;
2573 sname.ReplaceAll(".C", "");
2574 out << sname.Data() << "()" << std::endl;
2575 out << "{" << std::endl;
2576 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2577 out << "//=== Voxel optimization for " << GetTitle() << " geometry" << std::endl;
2578 out << "//===== <run this macro JUST BEFORE closing the geometry>" << std::endl;
2579 out << " TGeoVolume *vol = 0;" << std::endl;
2580 out << " // parse all voxelized volumes" << std::endl;
2581 TGeoVolume *vol = nullptr;
2583 TIter next(fVolumes);
2584 while ((vol = (TGeoVolume *)next())) {
2585 if (!vol->GetVoxels())
2586 continue;
2587 out << " vol = gGeoManager->GetVolume(\"" << vol->GetName() << "\");" << std::endl;
2588 cyltype = vol->OptimizeVoxels();
2589 if (cyltype) {
2590 out << " vol->SetCylVoxels();" << std::endl;
2591 } else {
2592 out << " vol->SetCylVoxels(kFALSE);" << std::endl;
2593 }
2594 }
2595 out << "}" << std::endl;
2596 out.close();
2597}
2598////////////////////////////////////////////////////////////////////////////////
2599/// Parse a string boolean expression and do a syntax check. Find top
2600/// level boolean operator and returns its type. Fill the two
2601/// substrings to which this operator applies. The returned integer is :
2602/// - -1 : parse error
2603/// - 0 : no boolean operator
2604/// - 1 : union - represented as '+' in expression
2605/// - 2 : difference (subtraction) - represented as '-' in expression
2606/// - 3 : intersection - represented as '*' in expression.
2607/// Parentheses should be used to avoid ambiguities. For instance :
2608/// - A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2609/// eliminate not needed parentheses
2610
2612{
2614 Int_t len = startstr.Length();
2615 Int_t i;
2616 TString e0 = "";
2617 expr3 = "";
2618 // eliminate blanks
2619 for (i = 0; i < len; i++) {
2620 if (startstr(i) == ' ')
2621 continue;
2622 e0 += startstr(i, 1);
2623 }
2624 Int_t level = 0;
2625 Int_t levmin = 999;
2626 Int_t boolop = 0;
2627 Int_t indop = 0;
2628 Int_t iloop = 1;
2629 Int_t lastop = 0;
2630 Int_t lastdp = 0;
2631 Int_t lastpp = 0;
2633 // check/eliminate parentheses
2634 while (iloop == 1) {
2635 iloop = 0;
2636 lastop = 0;
2637 lastdp = 0;
2638 lastpp = 0;
2639 len = e0.Length();
2640 for (i = 0; i < len; i++) {
2641 if (e0(i) == '(') {
2642 if (!level)
2643 iloop++;
2644 level++;
2645 continue;
2646 }
2647 if (e0(i) == ')') {
2648 level--;
2649 if (level == 0)
2650 lastpp = i;
2651 continue;
2652 }
2653 if ((e0(i) == '+') || (e0(i) == '-') || (e0(i) == '*')) {
2654 lastop = i;
2655 if (level < levmin) {
2656 levmin = level;
2657 indop = i;
2658 }
2659 continue;
2660 }
2661 if ((e0(i) == ':') && (level == 0)) {
2662 lastdp = i;
2663 continue;
2664 }
2665 }
2666 if (level != 0) {
2667 if (gGeoManager)
2668 gGeoManager->Error("Parse", "parentheses does not match");
2669 return -1;
2670 }
2671 if (iloop == 1 && (e0(0) == '(') && (e0(len - 1) == ')')) {
2672 // eliminate extra parentheses
2673 e0 = e0(1, len - 2);
2674 continue;
2675 }
2676 if (foundmat)
2677 break;
2678 if (((lastop == 0) && (lastdp > 0)) || ((lastpp > 0) && (lastdp > lastpp) && (indop < lastpp))) {
2679 expr3 = e0(lastdp + 1, len - lastdp);
2680 e0 = e0(0, lastdp);
2681 foundmat = kTRUE;
2682 iloop = 1;
2683 continue;
2684 } else
2685 break;
2686 }
2687 // loop expression and search parentheses/operators
2688 levmin = 999;
2689 for (i = 0; i < len; i++) {
2690 if (e0(i) == '(') {
2691 level++;
2692 continue;
2693 }
2694 if (e0(i) == ')') {
2695 level--;
2696 continue;
2697 }
2698 // Take LAST operator at lowest level (revision 28/07/08)
2699 if (level <= levmin) {
2700 if (e0(i) == '+') {
2701 boolop = 1; // union
2702 levmin = level;
2703 indop = i;
2704 }
2705 if (e0(i) == '-') {
2706 boolop = 2; // difference
2707 levmin = level;
2708 indop = i;
2709 }
2710 if (e0(i) == '*') {
2711 boolop = 3; // intersection
2712 levmin = level;
2713 indop = i;
2714 }
2715 }
2716 }
2717 if (indop == 0) {
2718 expr1 = e0;
2719 return indop;
2720 }
2721 expr1 = e0(0, indop);
2722 expr2 = e0(indop + 1, len - indop);
2723 return boolop;
2724}
2725
2726////////////////////////////////////////////////////////////////////////////////
2727/// Save current attributes in a macro
2728
2730{
2731 if (!fTopNode) {
2732 Error("SaveAttributes", "geometry must be closed first\n");
2733 return;
2734 }
2735 std::ofstream out;
2737 if (fname.IsNull())
2738 fname = "tgeoatt.C";
2739 out.open(fname, std::ios::out);
2740 if (!out.good()) {
2741 Error("SaveAttributes", "cannot open file");
2742 return;
2743 }
2744 // write header
2745 TDatime t;
2747 sname.ReplaceAll(".C", "");
2748 out << sname.Data() << "()" << std::endl;
2749 out << "{" << std::endl;
2750 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2751 out << "//=== Attributes for " << GetTitle() << " geometry" << std::endl;
2752 out << "//===== <run this macro AFTER loading the geometry in memory>" << std::endl;
2753 // save current top volume
2754 out << " TGeoVolume *top = gGeoManager->GetVolume(\"" << fTopVolume->GetName() << "\");" << std::endl;
2755 out << " TGeoVolume *vol = 0;" << std::endl;
2756 out << " TGeoNode *node = 0;" << std::endl;
2757 out << " // clear all volume attributes and get painter" << std::endl;
2758 out << " gGeoManager->ClearAttributes();" << std::endl;
2759 out << " gGeoManager->GetGeomPainter();" << std::endl;
2760 out << " // set visualization modes and bomb factors" << std::endl;
2761 out << " gGeoManager->SetVisOption(" << GetVisOption() << ");" << std::endl;
2762 out << " gGeoManager->SetVisLevel(" << GetVisLevel() << ");" << std::endl;
2763 out << " gGeoManager->SetExplodedView(" << GetBombMode() << ");" << std::endl;
2766 out << " gGeoManager->SetBombFactors(" << bombx << "," << bomby << "," << bombz << "," << bombr << ");"
2767 << std::endl;
2768 out << " // iterate volumes container and set new attributes" << std::endl;
2769 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2770 TGeoVolume *vol = nullptr;
2772
2773 TIter next(fVolumes);
2774 while ((vol = (TGeoVolume *)next())) {
2775 vol->SetVisStreamed(kFALSE);
2776 }
2777 out << " // draw top volume with new settings" << std::endl;
2778 out << " top->Draw();" << std::endl;
2779 out << "}" << std::endl;
2780 out.close();
2781}
2782
2783////////////////////////////////////////////////////////////////////////////////
2784/// Returns the deepest node containing fPoint, which must be set a priori.
2785
2790
2791////////////////////////////////////////////////////////////////////////////////
2792/// Cross next boundary and locate within current node
2793/// The current point must be on the boundary of fCurrentNode.
2794
2799
2800////////////////////////////////////////////////////////////////////////////////
2801/// Compute distance to next boundary within STEPMAX. If no boundary is found,
2802/// propagate current point along current direction with fStep=STEPMAX. Otherwise
2803/// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2804/// node.
2805
2810
2811////////////////////////////////////////////////////////////////////////////////
2812/// Find distance to next boundary and store it in fStep. Returns node to which this
2813/// boundary belongs. If PATH is specified, compute only distance to the node to which
2814/// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2815/// than this value. STEPMAX represent the step to be made imposed by other reasons than
2816/// geometry (usually physics processes). Therefore in this case this method provides the
2817/// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2818/// fStep with a big number.
2819/// In case frombdr=kTRUE, the isotropic safety is set to zero.
2820///
2821/// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2822/// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2823/// they want this computed for the current point.
2824
2826{
2827 // convert current point and direction to local reference
2829}
2830
2831////////////////////////////////////////////////////////////////////////////////
2832/// Computes as fStep the distance to next daughter of the current volume.
2833/// The point and direction must be converted in the coordinate system of the current volume.
2834/// The proposed step limit is fStep.
2835
2840
2841////////////////////////////////////////////////////////////////////////////////
2842/// Reset current state flags.
2843
2848
2849////////////////////////////////////////////////////////////////////////////////
2850/// Returns deepest node containing current point.
2851
2856
2857////////////////////////////////////////////////////////////////////////////////
2858/// Returns deepest node containing current point.
2859
2864
2865////////////////////////////////////////////////////////////////////////////////
2866/// Computes fast normal to next crossed boundary, assuming that the current point
2867/// is close enough to the boundary. Works only after calling FindNextBoundary.
2868
2873
2874////////////////////////////////////////////////////////////////////////////////
2875/// Computes normal vector to the next surface that will be or was already
2876/// crossed when propagating on a straight line from a given point/direction.
2877/// Returns the normal vector cosines in the MASTER coordinate system. The dot
2878/// product of the normal and the current direction is positive defined.
2879
2881{
2882 return GetCurrentNavigator()->FindNormal(forward);
2883}
2884
2885////////////////////////////////////////////////////////////////////////////////
2886/// Checks if point (x,y,z) is still in the current node.
2887
2892
2893////////////////////////////////////////////////////////////////////////////////
2894/// Check if a new point with given coordinates is the same as the last located one.
2895
2900
2901////////////////////////////////////////////////////////////////////////////////
2902/// True if current node is in phi range
2903
2905{
2906 if (!fPhiCut)
2907 return kTRUE;
2908 const Double_t *origin;
2910 return kFALSE;
2911 origin = ((TGeoBBox *)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2912 Double_t point[3];
2913 LocalToMaster(origin, &point[0]);
2914 Double_t phi = TMath::ATan2(point[1], point[0]) * TMath::RadToDeg();
2915 if (phi < 0)
2916 phi += 360.;
2917 if ((phi >= fPhimin) && (phi <= fPhimax))
2918 return kFALSE;
2919 return kTRUE;
2920}
2921
2922////////////////////////////////////////////////////////////////////////////////
2923/// Initialize current point and current direction vector (normalized)
2924/// in MARS. Return corresponding node.
2925
2927{
2928 return GetCurrentNavigator()->InitTrack(point, dir);
2929}
2930
2931////////////////////////////////////////////////////////////////////////////////
2932/// Initialize current point and current direction vector (normalized)
2933/// in MARS. Return corresponding node.
2934
2939
2940////////////////////////////////////////////////////////////////////////////////
2941/// Inspects path and all flags for the current state.
2942
2947
2948////////////////////////////////////////////////////////////////////////////////
2949/// Get path to the current node in the form /node0/node1/...
2950
2951const char *TGeoManager::GetPath() const
2952{
2953 return GetCurrentNavigator()->GetPath();
2954}
2955
2956////////////////////////////////////////////////////////////////////////////////
2957/// Get total size of geometry in bytes.
2958
2960{
2961 Int_t count = 0;
2962 TIter next(fVolumes);
2963 TGeoVolume *vol;
2964 while ((vol = (TGeoVolume *)next()))
2965 count += vol->GetByteCount();
2968 while ((matrix = (TGeoMatrix *)next1()))
2969 count += matrix->GetByteCount();
2972 while ((mat = (TGeoMaterial *)next2()))
2973 count += mat->GetByteCount();
2975 TGeoMedium *med;
2976 while ((med = (TGeoMedium *)next3()))
2977 count += med->GetByteCount();
2978 if (fgVerboseLevel > 0)
2979 Info("GetByteCount", "Total size of logical tree : %i bytes", count);
2980 return count;
2981}
2982
2983////////////////////////////////////////////////////////////////////////////////
2984/// Make a default painter if none present. Returns pointer to it.
2985
2987{
2988 if (!fPainter) {
2989 const char *kind = nullptr;
2990 if (gPad)
2991 kind = gPad->IsWeb() ? "web" : "root";
2992 else
2993 kind = gEnv->GetValue("GeomPainter.Name", "");
2994
2995 if (!kind || !*kind)
2996 kind = (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch()) ? "web" : "root";
2997
2998 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter", kind)) {
2999 if (h->LoadPlugin() == -1) {
3000 Error("GetGeomPainter", "could not load plugin for %s geo_painter", kind);
3001 return nullptr;
3002 }
3003 fPainter = (TVirtualGeoPainter *)h->ExecPlugin(1, this);
3004 if (!fPainter) {
3005 Error("GetGeomPainter", "could not create %s geo_painter", kind);
3006 return nullptr;
3007 }
3008 } else {
3009 Error("GetGeomPainter", "not found plugin %s for geo_painter", kind);
3010 }
3011 }
3012 return fPainter;
3013}
3014
3015////////////////////////////////////////////////////////////////////////////////
3016/// Make a default checker if none present. Returns pointer to it.
3017
3019{
3020 if (!fChecker) {
3021 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoChecker", "root")) {
3022 if (h->LoadPlugin() == -1) {
3023 Error("GetGeomChecker", "could not load plugin for geo_checker");
3024 return nullptr;
3025 }
3026 fChecker = (TVirtualGeoChecker *)h->ExecPlugin(1, this);
3027 if (!fChecker) {
3028 Error("GetGeomChecker", "could not create geo_checker");
3029 return nullptr;
3030 }
3031 } else {
3032 Error("GetGeomChecker", "not found plugin for geo_checker");
3033 }
3034 }
3035 return fChecker;
3036}
3037
3038////////////////////////////////////////////////////////////////////////////////
3039/// Search for a named volume. All trailing blanks stripped.
3040
3042{
3043 TString sname = name;
3044 sname = sname.Strip();
3045 TGeoVolume *vol = (TGeoVolume *)fVolumes->FindObject(sname.Data());
3046 return vol;
3047}
3048
3049////////////////////////////////////////////////////////////////////////////////
3050/// Fast search for a named volume. All trailing blanks stripped.
3051
3053{
3054 if (!fHashVolumes) {
3057 fHashVolumes = new THashList(nvol + 1, 3);
3058 fHashGVolumes = new THashList(ngvol + 1, 3);
3059 Int_t i;
3060 for (i = 0; i < ngvol; i++)
3062 for (i = 0; i < nvol; i++)
3064 }
3065 TString sname = name;
3066 sname = sname.Strip();
3067 THashList *list = fHashVolumes;
3068 if (multi)
3069 list = fHashGVolumes;
3070 TGeoVolume *vol = (TGeoVolume *)list->FindObject(sname.Data());
3071 return vol;
3072}
3073
3074////////////////////////////////////////////////////////////////////////////////
3075/// Retrieve unique id for a volume name. Return -1 if name not found.
3076
3078{
3079 TGeoManager *geom = (TGeoManager *)this;
3080 TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
3081 if (!vol)
3082 vol = geom->FindVolumeFast(volname, kTRUE);
3083 if (!vol)
3084 return -1;
3085 return vol->GetNumber();
3086}
3087
3088////////////////////////////////////////////////////////////////////////////////
3089/// Find if a given material duplicates an existing one.
3090
3092{
3094 if (index <= 0)
3095 return nullptr;
3097 for (Int_t i = 0; i < index; i++) {
3099 if (other == mat)
3100 continue;
3101 if (other->IsEq(mat))
3102 return other;
3103 }
3104 return nullptr;
3105}
3106
3107////////////////////////////////////////////////////////////////////////////////
3108/// Search for a named material. All trailing blanks stripped.
3109
3111{
3113 sname = sname.Strip();
3115 return mat;
3116}
3117
3118////////////////////////////////////////////////////////////////////////////////
3119/// Search for a named tracking medium. All trailing blanks stripped.
3120
3122{
3124 sname = sname.Strip();
3126 return med;
3127}
3128
3129////////////////////////////////////////////////////////////////////////////////
3130/// Search for a tracking medium with a given ID.
3131
3133{
3134 TIter next(fMedia);
3135 TGeoMedium *med;
3136 while ((med = (TGeoMedium *)next())) {
3137 if (med->GetId() == numed)
3138 return med;
3139 }
3140 return nullptr;
3141}
3142
3143////////////////////////////////////////////////////////////////////////////////
3144/// Return material at position id.
3145
3147{
3149 return nullptr;
3151 return mat;
3152}
3153
3154////////////////////////////////////////////////////////////////////////////////
3155/// Return index of named material.
3156
3158{
3159 TIter next(fMaterials);
3161 Int_t id = 0;
3163 sname = sname.Strip();
3164 while ((mat = (TGeoMaterial *)next())) {
3165 if (!strcmp(mat->GetName(), sname.Data()))
3166 return id;
3167 id++;
3168 }
3169 return -1; // fail
3170}
3171
3172////////////////////////////////////////////////////////////////////////////////
3173/// Randomly shoot nrays and plot intersections with surfaces for current
3174/// top node.
3175
3181
3182////////////////////////////////////////////////////////////////////////////////
3183/// Remove material at given index.
3184
3186{
3187 TObject *obj = fMaterials->At(index);
3188 if (obj)
3189 fMaterials->Remove(obj);
3190}
3191
3192////////////////////////////////////////////////////////////////////////////////
3193/// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
3194/// from geometry. Deletion has to be managed by users.
3195
3197{
3198 TIter next(fVolumes);
3199 TGeoVolume *vol;
3200 while ((vol = (TGeoVolume *)next()))
3201 vol->SetField(nullptr);
3202}
3203
3204////////////////////////////////////////////////////////////////////////////////
3205/// Change raytracing mode.
3206
3213
3214////////////////////////////////////////////////////////////////////////////////
3215/// Restore the master volume of the geometry.
3216
3218{
3220 return;
3221 if (fMasterVolume)
3223}
3224
3225////////////////////////////////////////////////////////////////////////////////
3226/// Voxelize all non-divided volumes.
3227
3229{
3230 TGeoVolume *vol;
3231 // TGeoVoxelFinder *vox = 0;
3232 if (!fStreamVoxels && fgVerboseLevel > 0)
3233 Info("Voxelize", "Voxelizing...");
3234 // Int_t nentries = fVolumes->GetSize();
3235 TIter next(fVolumes);
3236 while ((vol = (TGeoVolume *)next())) {
3237 if (!fIsGeomReading)
3238 vol->SortNodes();
3239 if (!fStreamVoxels) {
3240 vol->Voxelize(option);
3241 }
3242 if (!fIsGeomReading)
3243 vol->FindOverlaps();
3244 }
3245}
3246
3247////////////////////////////////////////////////////////////////////////////////
3248/// Send "Modified" signal to painter.
3249
3251{
3252 if (!fPainter)
3253 return;
3255}
3256
3257////////////////////////////////////////////////////////////////////////////////
3258/// Make an TGeoArb8 volume.
3259
3261{
3262 return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
3263}
3264
3265////////////////////////////////////////////////////////////////////////////////
3266/// Make in one step a volume pointing to a box shape with given medium.
3267
3272
3273////////////////////////////////////////////////////////////////////////////////
3274/// Make in one step a volume pointing to a parallelepiped shape with given medium.
3275
3277 Double_t alpha, Double_t theta, Double_t phi)
3278{
3279 return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
3280}
3281
3282////////////////////////////////////////////////////////////////////////////////
3283/// Make in one step a volume pointing to a sphere shape with given medium
3284
3290
3291////////////////////////////////////////////////////////////////////////////////
3292/// Make in one step a volume pointing to a torus shape with given medium.
3293
3299
3300////////////////////////////////////////////////////////////////////////////////
3301/// Make in one step a volume pointing to a tube shape with given medium.
3302
3307
3308////////////////////////////////////////////////////////////////////////////////
3309/// Make in one step a volume pointing to a tube segment shape with given medium.
3310/// The segment will be from phiStart to phiEnd, the angles are expressed in degree
3311
3317
3318////////////////////////////////////////////////////////////////////////////////
3319/// Make in one step a volume pointing to a tube shape with given medium
3320
3322{
3323 return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
3324}
3325
3326////////////////////////////////////////////////////////////////////////////////
3327/// Make in one step a volume pointing to a tube shape with given medium
3328
3334
3335////////////////////////////////////////////////////////////////////////////////
3336/// Make in one step a volume pointing to a tube shape with given medium
3337
3342
3343////////////////////////////////////////////////////////////////////////////////
3344/// Make in one step a volume pointing to a tube segment shape with given medium
3345
3352
3353////////////////////////////////////////////////////////////////////////////////
3354/// Make in one step a volume pointing to a cone shape with given medium.
3355
3361
3362////////////////////////////////////////////////////////////////////////////////
3363/// Make in one step a volume pointing to a cone segment shape with given medium
3364
3370
3371////////////////////////////////////////////////////////////////////////////////
3372/// Make in one step a volume pointing to a polycone shape with given medium.
3373
3375{
3376 return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3377}
3378
3379////////////////////////////////////////////////////////////////////////////////
3380/// Make in one step a volume pointing to a polygone shape with given medium.
3381
3382TGeoVolume *
3384{
3385 return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3386}
3387
3388////////////////////////////////////////////////////////////////////////////////
3389/// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3390
3391TGeoVolume *
3396
3397////////////////////////////////////////////////////////////////////////////////
3398/// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3399
3405
3406////////////////////////////////////////////////////////////////////////////////
3407/// Make in one step a volume pointing to a trapezoid shape with given medium.
3408
3412{
3413 return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2,
3414 alpha2);
3415}
3416
3417////////////////////////////////////////////////////////////////////////////////
3418/// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3419
3427
3428////////////////////////////////////////////////////////////////////////////////
3429/// Make a TGeoXtru-shaped volume with nz planes
3430
3432{
3433 return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3434}
3435
3436////////////////////////////////////////////////////////////////////////////////
3437/// Creates an alignable object with unique name corresponding to a path
3438/// and adds it to the list of alignables. An optional unique ID can be
3439/// provided, in which case PN entries can be searched fast by uid.
3440
3442{
3443 if (!CheckPath(path))
3444 return nullptr;
3445 if (!fHashPNE)
3446 fHashPNE = new THashList(256, 3);
3447 if (!fArrayPNE)
3448 fArrayPNE = new TObjArray(256);
3450 if (entry) {
3451 Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3452 return nullptr;
3453 }
3454 entry = new TGeoPNEntry(unique_name, path);
3456 fHashPNE->Add(entry);
3458 if (uid >= 0) {
3460 if (!added)
3461 Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3462 }
3463 return entry;
3464}
3465
3466////////////////////////////////////////////////////////////////////////////////
3467/// Retrieves an existing alignable object.
3468
3470{
3471 if (!fHashPNE)
3472 return nullptr;
3473 return (TGeoPNEntry *)fHashPNE->FindObject(name);
3474}
3475
3476////////////////////////////////////////////////////////////////////////////////
3477/// Retrieves an existing alignable object at a given index.
3478
3480{
3481 if (!fArrayPNE && !InitArrayPNE())
3482 return nullptr;
3483 return (TGeoPNEntry *)fArrayPNE->At(index);
3484}
3485
3486////////////////////////////////////////////////////////////////////////////////
3487/// Retrieves an existing alignable object having a preset UID.
3488
3490{
3491 if (!fNPNEId || (!fArrayPNE && !InitArrayPNE()))
3492 return nullptr;
3494 if (index < 0 || fKeyPNEId[index] != uid)
3495 return nullptr;
3497}
3498
3499////////////////////////////////////////////////////////////////////////////////
3500/// Retrieves number of PN entries with or without UID.
3501
3503{
3504 if (!fHashPNE)
3505 return 0;
3506 if (with_uid)
3507 return fNPNEId;
3508 return fHashPNE->GetSize();
3509}
3510
3511////////////////////////////////////////////////////////////////////////////////
3512/// Insert a PN entry in the sorted array of indexes.
3513
3515{
3516 if (!fSizePNEId) {
3517 // Create the arrays.
3518 fSizePNEId = 128;
3519 fKeyPNEId = new Int_t[fSizePNEId];
3520 memset(fKeyPNEId, 0, fSizePNEId * sizeof(Int_t));
3522 memset(fValuePNEId, 0, fSizePNEId * sizeof(Int_t));
3523 fKeyPNEId[fNPNEId] = uid;
3525 return kTRUE;
3526 }
3527 // Search id in the existing array and return false if it already exists.
3529 if (index > 0 && fKeyPNEId[index] == uid)
3530 return kFALSE;
3531 // Resize the arrays and insert the value
3532 Bool_t resize = (fNPNEId == fSizePNEId) ? kTRUE : kFALSE;
3533 if (resize) {
3534 // Double the size of the array
3535 fSizePNEId *= 2;
3536 // Create new arrays of keys and values
3537 Int_t *keys = new Int_t[fSizePNEId];
3538 memset(keys, 0, fSizePNEId * sizeof(Int_t));
3539 Int_t *values = new Int_t[fSizePNEId];
3540 memset(values, 0, fSizePNEId * sizeof(Int_t));
3541 // Copy all keys<uid in the new keys array (0 to index)
3542 memcpy(keys, fKeyPNEId, (index + 1) * sizeof(Int_t));
3543 memcpy(values, fValuePNEId, (index + 1) * sizeof(Int_t));
3544 // Insert current key at index+1
3545 keys[index + 1] = uid;
3546 values[index + 1] = ientry;
3547 // Copy all remaining keys from the old to new array
3548 memcpy(&keys[index + 2], &fKeyPNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3549 memcpy(&values[index + 2], &fValuePNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3550 delete[] fKeyPNEId;
3551 fKeyPNEId = keys;
3552 delete[] fValuePNEId;
3553 fValuePNEId = values;
3554 fNPNEId++;
3555 return kTRUE;
3556 }
3557 // Insert the value in the existing arrays
3558 Int_t i;
3559 for (i = fNPNEId - 1; i > index; i--) {
3560 fKeyPNEId[i + 1] = fKeyPNEId[i];
3561 fValuePNEId[i + 1] = fValuePNEId[i];
3562 }
3563 fKeyPNEId[index + 1] = uid;
3564 fValuePNEId[index + 1] = ientry;
3565 fNPNEId++;
3566 return kTRUE;
3567}
3568
3569////////////////////////////////////////////////////////////////////////////////
3570/// Make a physical node from the path pointed by an alignable object with a given name.
3571
3573{
3575 if (!entry) {
3576 Error("MakeAlignablePN", "No alignable object named %s found !", name);
3577 return nullptr;
3578 }
3579 return MakeAlignablePN(entry);
3580}
3581
3582////////////////////////////////////////////////////////////////////////////////
3583/// Make a physical node from the path pointed by a given alignable object.
3584
3586{
3587 if (!entry) {
3588 Error("MakeAlignablePN", "No alignable object specified !");
3589 return nullptr;
3590 }
3591 const char *path = entry->GetTitle();
3592 if (!cd(path)) {
3593 Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s", entry->GetName(), path);
3594 return nullptr;
3595 }
3596 TGeoPhysicalNode *node = MakePhysicalNode(path);
3597 entry->SetPhysicalNode(node);
3598 return node;
3599}
3600
3601////////////////////////////////////////////////////////////////////////////////
3602/// Makes a physical node corresponding to a path. If PATH is not specified,
3603/// makes physical node matching current modeller state.
3604
3606{
3607 TGeoPhysicalNode *node;
3608 if (path) {
3609 if (!CheckPath(path)) {
3610 Error("MakePhysicalNode", "path: %s not valid", path);
3611 return nullptr;
3612 }
3613 node = new TGeoPhysicalNode(path);
3614 } else {
3615 node = new TGeoPhysicalNode(GetPath());
3616 }
3617 fPhysicalNodes->Add(node);
3618 return node;
3619}
3620
3621////////////////////////////////////////////////////////////////////////////////
3622/// Refresh physical nodes to reflect the actual geometry paths after alignment
3623/// was applied. Optionally locks physical nodes (default).
3624
3626{
3629 while ((pn = (TGeoPhysicalNode *)next()))
3630 pn->Refresh();
3633 if (lock)
3634 LockGeometry();
3635}
3636
3637////////////////////////////////////////////////////////////////////////////////
3638/// Clear the current list of physical nodes, so that we can start over with a new list.
3639/// If MUSTDELETE is true, delete previous nodes.
3640
3648
3649////////////////////////////////////////////////////////////////////////////////
3650/// Make an assembly of volumes.
3651
3653{
3654 return TGeoBuilder::Instance(this)->MakeVolumeAssembly(name);
3655}
3656
3657////////////////////////////////////////////////////////////////////////////////
3658/// Make a TGeoVolumeMulti handling a list of volumes.
3659
3661{
3662 return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3663}
3664
3665////////////////////////////////////////////////////////////////////////////////
3666/// Set type of exploding view (see TGeoPainter::SetExplodedView())
3667
3669{
3670 if ((ibomb >= 0) && (ibomb < 4))
3672 if (fPainter)
3674}
3675
3676////////////////////////////////////////////////////////////////////////////////
3677/// Set cut phi range
3678
3680{
3681 if ((phimin == 0) && (phimax == 360)) {
3682 fPhiCut = kFALSE;
3683 return;
3684 }
3685 fPhiCut = kTRUE;
3686 fPhimin = phimin;
3687 fPhimax = phimax;
3688}
3689
3690////////////////////////////////////////////////////////////////////////////////
3691/// Set number of segments for approximating circles in drawing.
3692
3694{
3695 if (fNsegments == nseg)
3696 return;
3697 if (nseg > 2)
3698 fNsegments = nseg;
3699 if (fPainter)
3702}
3703
3704////////////////////////////////////////////////////////////////////////////////
3705/// Get number of segments approximating circles
3706
3708{
3709 return fNsegments;
3710}
3711
3712////////////////////////////////////////////////////////////////////////////////
3713/// Invalidate mesh caches built by composite shapes
3714
3716{
3718 TGeoShape *shape;
3719 while ((shape = (TGeoShape *)next_shape())) {
3720 if (shape->IsComposite())
3721 ((TGeoCompositeShape *)shape)->InvalidateMeshCaches();
3722 }
3723}
3724
3725////////////////////////////////////////////////////////////////////////////////
3726/// Now just a shortcut for GetElementTable.
3727
3733
3734////////////////////////////////////////////////////////////////////////////////
3735/// Returns material table. Creates it if not existing.
3736
3743
3744////////////////////////////////////////////////////////////////////////////////
3745/// Make a rectilinear step of length fStep from current point (fPoint) on current
3746/// direction (fDirection). If the step is imposed by geometry, is_geom flag
3747/// must be true (default). The cross flag specifies if the boundary should be
3748/// crossed in case of a geometry step (default true). Returns new node after step.
3749/// Set also on boundary condition.
3750
3752{
3753 return GetCurrentNavigator()->Step(is_geom, cross);
3754}
3755
3756////////////////////////////////////////////////////////////////////////////////
3757/// shoot npoints randomly in a box of 1E-5 around current point.
3758/// return minimum distance to points outside
3759
3764
3765////////////////////////////////////////////////////////////////////////////////
3766/// Set the top volume and corresponding node as starting point of the geometry.
3767
3769{
3770 if (fTopVolume == vol)
3771 return;
3772
3773 TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3774 TIter next(brlist);
3775 TBrowser *browser = nullptr;
3776
3777 if (fTopVolume)
3778 fTopVolume->SetTitle("");
3779 fTopVolume = vol;
3780 vol->SetTitle("Top volume");
3781 if (fTopNode) {
3783 fTopNode = nullptr;
3784 while ((browser = (TBrowser *)next()))
3785 browser->RecursiveRemove(topn);
3786 delete topn;
3787 } else {
3788 fMasterVolume = vol;
3791 if (fgVerboseLevel > 0)
3792 Info("SetTopVolume", "Top volume is %s. Master volume is %s", fTopVolume->GetName(), fMasterVolume->GetName());
3793 }
3794 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3795 // fCurrentMatrix->Print();
3797 fTopNode->SetName(TString::Format("%s_1", vol->GetName()));
3798 fTopNode->SetNumber(1);
3799 fTopNode->SetTitle("Top logical node");
3800 fNodes->AddAt(fTopNode, 0);
3801 if (!GetCurrentNavigator()) {
3803 return;
3804 }
3805 Int_t nnavigators = 0;
3807 if (!arr)
3808 return;
3809 nnavigators = arr->GetEntriesFast();
3810 for (Int_t i = 0; i < nnavigators; i++) {
3811 TGeoNavigator *nav = (TGeoNavigator *)arr->At(i);
3812 nav->ResetAll();
3813 if (fClosed)
3814 nav->GetCache()->BuildInfoBranch();
3815 }
3816}
3817
3818////////////////////////////////////////////////////////////////////////////////
3819/// Define different tracking media.
3820
3822{
3823 /*
3824 Int_t nmat = fMaterials->GetSize();
3825 if (!nmat) {printf(" No materials !\n"); return;}
3826 Int_t *media = new Int_t[nmat];
3827 memset(media, 0, nmat*sizeof(Int_t));
3828 Int_t imedia = 1;
3829 TGeoMaterial *mat, *matref;
3830 mat = (TGeoMaterial*)fMaterials->At(0);
3831 if (mat->GetMedia()) {
3832 for (Int_t i=0; i<nmat; i++) {
3833 mat = (TGeoMaterial*)fMaterials->At(i);
3834 mat->Print();
3835 }
3836 return;
3837 }
3838 mat->SetMedia(imedia);
3839 media[0] = imedia++;
3840 mat->Print();
3841 for (Int_t i=0; i<nmat; i++) {
3842 mat = (TGeoMaterial*)fMaterials->At(i);
3843 for (Int_t j=0; j<i; j++) {
3844 matref = (TGeoMaterial*)fMaterials->At(j);
3845 if (mat->IsEq(matref)) {
3846 mat->SetMedia(media[j]);
3847 break;
3848 }
3849 if (j==(i-1)) {
3850 // different material
3851 mat->SetMedia(imedia);
3852 media[i] = imedia++;
3853 mat->Print();
3854 }
3855 }
3856 }
3857 */
3858}
3859
3860////////////////////////////////////////////////////////////////////////////////
3861/// Check pushes and pulls needed to cross the next boundary with respect to the
3862/// position given by FindNextBoundary. If radius is not mentioned the full bounding
3863/// box will be sampled.
3864
3869
3870////////////////////////////////////////////////////////////////////////////////
3871/// Check the boundary errors reference file created by CheckBoundaryErrors method.
3872/// The shape for which the crossing failed is drawn with the starting point in red
3873/// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3874
3879
3880////////////////////////////////////////////////////////////////////////////////
3881/// Classify a given point. See TGeoChecker::CheckPoint().
3882
3887
3888////////////////////////////////////////////////////////////////////////////////
3889/// Test for shape navigation methods. Summary for test numbers:
3890/// - 1: DistFromInside/Outside. Sample points inside the shape. Generate
3891/// directions randomly in cos(theta). Compute DistFromInside and move the
3892/// point with bigger distance. Compute DistFromOutside back from new point.
3893/// Plot d-(d1+d2)
3894///
3895
3900
3901////////////////////////////////////////////////////////////////////////////////
3902/// Geometry checking.
3903/// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3904/// - if option contains 'b': Optional boundary crossing check + timing per volume.
3905///
3906/// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3907/// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3908/// be called for the suspicious volumes.
3909///
3910/// STAGE 2: normal overlap checking using the shapes mesh - fills the list of
3911/// overlaps.
3912///
3913/// STAGE 3: shooting NRAYS rays from VERTEX and counting the total number of
3914/// crossings per volume (rays propagated from boundary to boundary until
3915/// geometry exit). Timing computed and results stored in a histo.
3916///
3917/// STAGE 4: shooting 1 mil. random rays inside EACH volume and calling
3918/// FindNextBoundary() + Safety() for each call. The timing is normalized by the
3919/// number of crossings computed at stage 2 and presented as percentage.
3920/// One can get a picture on which are the most "burned" volumes during
3921/// transportation from geometry point of view. Another plot of the timing per
3922/// volume vs. number of daughters is produced.
3923
3925{
3926 TString opt(option);
3927 opt.ToLower();
3928 if (!opt.Length()) {
3929 Error("CheckGeometryFull", "The option string must contain a letter. See method documentation.");
3930 return;
3931 }
3932 Bool_t checkoverlaps = opt.Contains("o");
3933 Bool_t checkcrossings = opt.Contains("b");
3934 Double_t vertex[3];
3935 vertex[0] = vx;
3936 vertex[1] = vy;
3937 vertex[2] = vz;
3939}
3940
3941////////////////////////////////////////////////////////////////////////////////
3942/// Perform last checks on the geometry
3943
3945{
3946 if (fgVerboseLevel > 0)
3947 Info("CheckGeometry", "Fixing runtime shapes...");
3948 TIter next(fShapes);
3950 TGeoShape *shape;
3951 TGeoVolume *vol;
3953 while ((shape = (TGeoShape *)next())) {
3954 if (shape->IsRunTimeShape()) {
3956 }
3957 if (fIsGeomReading)
3958 shape->AfterStreamer();
3961 shape->ComputeBBox();
3962 }
3963 if (has_runtime)
3965 else if (fgVerboseLevel > 0)
3966 Info("CheckGeometry", "...Nothing to fix");
3967 // Compute bounding box for assemblies
3969 while ((vol = (TGeoVolume *)nextv())) {
3970 if (vol->IsAssembly())
3971 vol->GetShape()->ComputeBBox();
3972 else if (vol->GetMedium() == dummy) {
3973 Warning("CheckGeometry", "Volume \"%s\" has no medium: assigned dummy medium and material", vol->GetName());
3974 vol->SetMedium(dummy);
3975 }
3976 }
3977}
3978
3979////////////////////////////////////////////////////////////////////////////////
3980/// Check all geometry for illegal overlaps within a limit OVLP.
3981
3983{
3984 if (!fTopNode) {
3985 Error("CheckOverlaps", "Top node not set");
3986 return;
3987 }
3989}
3990
3991////////////////////////////////////////////////////////////////////////////////
3992/// Check all geometry for illegal overlaps within a limit OVLP.
3993
3995{
3996 if (!fTopNode) {
3997 Error("CheckOverlaps", "Top node not set");
3998 return;
3999 }
4001}
4002
4003////////////////////////////////////////////////////////////////////////////////
4004/// Prints the current list of overlaps.
4005
4007{
4008 if (!fOverlaps)
4009 return;
4011 if (!novlp)
4012 return;
4013 TGeoManager *geom = (TGeoManager *)this;
4014 geom->GetGeomChecker()->PrintOverlaps();
4015}
4016
4017////////////////////////////////////////////////////////////////////////////////
4018/// Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
4019/// Option can be "v" - verbose (default)
4020
4022{
4023 if (!GetGeomChecker())
4024 return 0.;
4025 TString opt(option);
4026 opt.ToLower();
4027 Double_t weight;
4028 TGeoVolume *volume = fTopVolume;
4029 if (opt.Contains("v")) {
4030 if (opt.Contains("a")) {
4031 if (fgVerboseLevel > 0)
4032 Info("Weight", "Computing analytically weight of %s", volume->GetName());
4033 weight = volume->WeightA();
4034 if (fgVerboseLevel > 0)
4035 Info("Weight", "Computed weight: %f [kg]\n", weight);
4036 return weight;
4037 }
4038 if (fgVerboseLevel > 0) {
4039 Info("Weight", "Estimating weight of %s with %g %% precision", fTopVolume->GetName(), 100. * precision);
4040 printf(" event weight err\n");
4041 printf("========================================\n");
4042 }
4043 }
4044 weight = fChecker->Weight(precision, option);
4045 return weight;
4046}
4047
4048////////////////////////////////////////////////////////////////////////////////
4049/// computes the total size in bytes of the branch starting with node.
4050/// The option can specify if all the branch has to be parsed or only the node
4051
4052ULong_t TGeoManager::SizeOf(const TGeoNode * /*node*/, Option_t * /*option*/)
4053{
4054 return 0;
4055}
4056
4057////////////////////////////////////////////////////////////////////////////////
4058/// Stream an object of class TGeoManager.
4059
4061{
4062 if (R__b.IsReading()) {
4063 R__b.ReadClassBuffer(TGeoManager::Class(), this);
4065 CloseGeometry();
4068 } else {
4069 R__b.WriteClassBuffer(TGeoManager::Class(), this);
4070 }
4071}
4072
4073////////////////////////////////////////////////////////////////////////////////
4074/// Execute mouse actions on this manager.
4075
4077{
4078 if (!fPainter)
4079 return;
4080 fPainter->ExecuteManagerEvent(this, event, px, py);
4081}
4082
4083////////////////////////////////////////////////////////////////////////////////
4084/// Export this geometry to a file
4085///
4086/// - Case 1: root file or root/xml file
4087/// if filename end with ".root". The key will be named name
4088/// By default the geometry is saved without the voxelisation info.
4089/// Use option 'v" to save the voxelisation info.
4090/// if filename end with ".xml" a root/xml file is produced.
4091///
4092/// - Case 2: C++ script
4093/// if filename end with ".C"
4094///
4095/// - Case 3: gdml file
4096/// if filename end with ".gdml"
4097/// NOTE that to use this option, the PYTHONPATH must be defined like
4098/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/geom/gdml
4099///
4100
4102{
4104 if (sfile.Contains(".C")) {
4105 // Save geometry as a C++ script
4106 if (fgVerboseLevel > 0)
4107 Info("Export", "Exporting %s %s as C++ code", GetName(), GetTitle());
4109 return 1;
4110 }
4111 if (sfile.Contains(".gdml")) {
4112 // Save geometry as a gdml file
4113 if (fgVerboseLevel > 0)
4114 Info("Export", "Exporting %s %s as gdml code", GetName(), GetTitle());
4115 // C++ version
4116 TString cmd;
4117 cmd = TString::Format("TGDMLWrite::StartGDMLWriting(gGeoManager,\"%s\",\"%s\")", filename, option);
4118 gROOT->ProcessLineFast(cmd);
4119 return 1;
4120 }
4121 if (sfile.Contains(".root") || sfile.Contains(".xml")) {
4122 // Save geometry as a root file
4123 TFile *f = TFile::Open(filename, "recreate");
4124 if (!f || f->IsZombie()) {
4125 Error("Export", "Cannot open file");
4126 return 0;
4127 }
4129 if (keyname.IsNull())
4130 keyname = GetName();
4131 TString opt = option;
4132 opt.ToLower();
4133 if (opt.Contains("v")) {
4135 if (fgVerboseLevel > 0)
4136 Info("Export", "Exporting %s %s as root file. Optimizations streamed.", GetName(), GetTitle());
4137 } else {
4139 if (fgVerboseLevel > 0)
4140 Info("Export", "Exporting %s %s as root file. Optimizations not streamed.", GetName(), GetTitle());
4141 }
4142
4146 if (sfile.Contains(".xml")) {
4149 }
4151 if (sfile.Contains(".xml")) {
4154 }
4155
4157 delete f;
4158 return nbytes;
4159 }
4160 return 0;
4161}
4162
4163////////////////////////////////////////////////////////////////////////////////
4164/// Lock current geometry so that no other geometry can be imported.
4165
4167{
4168 fgLock = kTRUE;
4169}
4170
4171////////////////////////////////////////////////////////////////////////////////
4172/// Unlock current geometry.
4173
4175{
4176 fgLock = kFALSE;
4177}
4178
4179////////////////////////////////////////////////////////////////////////////////
4180/// Check lock state.
4181
4183{
4184 return fgLock;
4185}
4186
4187////////////////////////////////////////////////////////////////////////////////
4188/// Set verbosity level (static function).
4189/// - 0 - suppress messages related to geom-painter visibility level
4190/// - 1 - default value
4191
4196
4197////////////////////////////////////////////////////////////////////////////////
4198/// Return current verbosity level (static function).
4199
4204
4205////////////////////////////////////////////////////////////////////////////////
4206/// static function
4207/// Import a geometry from a gdml or ROOT file
4208///
4209/// - Case 1: gdml
4210/// if filename ends with ".gdml" the foreign geometry described with gdml
4211/// is imported executing some python scripts in $ROOTSYS/gdml.
4212/// NOTE that to use this option, the PYTHONPATH must be defined like
4213/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
4214///
4215/// - Case 2: root file (.root) or root/xml file (.xml)
4216/// Import in memory from filename the geometry with key=name.
4217/// if name="" (default), the first TGeoManager object in the file is returned.
4218///
4219/// Note that this function deletes the current gGeoManager (if one)
4220/// before importing the new object.
4221
4222TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
4223{
4224 if (fgLock) {
4225 ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
4226 return nullptr;
4227 }
4228 if (!filename)
4229 return nullptr;
4230 if (fgVerboseLevel > 0)
4231 ::Info("TGeoManager::Import", "Reading geometry from file: %s", filename);
4232
4233 if (gGeoManager)
4234 delete gGeoManager;
4235 gGeoManager = nullptr;
4236
4237 if (strstr(filename, ".gdml")) {
4238 // import from a gdml file
4239 new TGeoManager("GDMLImport", "Geometry imported from GDML");
4240 TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
4241 TGeoVolume *world = (TGeoVolume *)gROOT->ProcessLineFast(cmd);
4242
4243 if (world == nullptr) {
4244 delete gGeoManager;
4245 gGeoManager = nullptr;
4246 ::Error("TGeoManager::Import", "Cannot read file %s", filename);
4247 } else {
4251 }
4252 } else {
4253 // import from a root file
4255 // in case a web file is specified, use the cacheread option to cache
4256 // this file in the cache directory
4257 TFile *f = nullptr;
4258 if (strstr(filename, "http"))
4259 f = TFile::Open(filename, "CACHEREAD");
4260 else
4262 if (!f || f->IsZombie()) {
4263 ::Error("TGeoManager::Import", "Cannot open file");
4264 return nullptr;
4265 }
4266 if (name && strlen(name) > 0) {
4267 gGeoManager = (TGeoManager *)f->Get(name);
4268 } else {
4269 TIter next(f->GetListOfKeys());
4270 TKey *key;
4271 while ((key = (TKey *)next())) {
4272 if (strcmp(key->GetClassName(), "TGeoManager") != 0)
4273 continue;
4274 gGeoManager = (TGeoManager *)key->ReadObj();
4275 break;
4276 }
4277 }
4278 delete f;
4279 }
4280 if (!gGeoManager)
4281 return nullptr;
4282 if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager))
4283 gROOT->GetListOfGeometries()->Add(gGeoManager);
4284 if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager))
4285 gROOT->GetListOfBrowsables()->Add(gGeoManager);
4287 return gGeoManager;
4288}
4289
4290////////////////////////////////////////////////////////////////////////////////
4291/// Update element flags when geometry is loaded from a file.
4292
4294{
4295 if (!fElementTable)
4296 return;
4297 TIter next(fMaterials);
4299 TGeoMixture *mix;
4301 Int_t i, nelem;
4302 while ((mat = (TGeoMaterial *)next())) {
4303 if (mat->IsMixture()) {
4304 mix = (TGeoMixture *)mat;
4305 nelem = mix->GetNelements();
4306 for (i = 0; i < nelem; i++) {
4307 elem = mix->GetElement(i);
4308 if (!elem)
4309 continue;
4311 if (!elem_table)
4312 continue;
4313 if (elem != elem_table) {
4314 elem_table->SetDefined(elem->IsDefined());
4315 elem_table->SetUsed(elem->IsUsed());
4316 } else {
4317 elem_table->SetDefined();
4318 }
4319 }
4320 } else {
4321 elem = mat->GetElement();
4322 if (!elem)
4323 continue;
4325 if (!elem_table)
4326 continue;
4327 if (elem != elem_table) {
4328 elem_table->SetDefined(elem->IsDefined());
4329 elem_table->SetUsed(elem->IsUsed());
4330 } else {
4331 elem_table->SetUsed();
4332 }
4333 }
4334 }
4335}
4336
4337////////////////////////////////////////////////////////////////////////////////
4338/// Initialize PNE array for fast access via index and unique-id.
4339
4341{
4342 if (fHashPNE) {
4344 TIter next(fHashPNE);
4345 TObject *obj;
4346 while ((obj = next())) {
4347 fArrayPNE->Add(obj);
4348 }
4349 return kTRUE;
4350 }
4351 return kFALSE;
4352}
4353
4354////////////////////////////////////////////////////////////////////////////////
4355/// Get time cut for drawing tracks.
4356
4358{
4359 tmin = fTmin;
4360 tmax = fTmax;
4361 return fTimeCut;
4362}
4363
4364////////////////////////////////////////////////////////////////////////////////
4365/// Set time cut interval for drawing tracks. If called with no arguments, time
4366/// cut will be disabled.
4367
4369{
4370 fTmin = tmin;
4371 fTmax = tmax;
4372 if (tmin == 0 && tmax == 999)
4373 fTimeCut = kFALSE;
4374 else
4375 fTimeCut = kTRUE;
4376 if (fTracks && !IsAnimatingTracks())
4377 ModifiedPad();
4378}
4379
4380////////////////////////////////////////////////////////////////////////////////
4381/// Convert coordinates from master volume frame to top.
4382
4387
4388////////////////////////////////////////////////////////////////////////////////
4389/// Convert coordinates from top volume frame to master.
4390
4395
4396////////////////////////////////////////////////////////////////////////////////
4397/// Create a parallel world for prioritised navigation. This can be populated
4398/// with physical nodes and can be navigated independently using its API.
4399/// In case the flag SetUseParallelWorldNav is set, any navigation query in the
4400/// main geometry is checked against the parallel geometry, which gets priority
4401/// in case of overlaps with the main geometry volumes.
4402
4408
4409////////////////////////////////////////////////////////////////////////////////
4410/// Activate/deactivate usage of parallel world navigation. Can only be done if
4411/// there is a parallel world. Activating navigation will automatically close
4412/// the parallel geometry.
4413
4415{
4416 if (!fParallelWorld) {
4417 Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
4418 return;
4419 }
4420 if (!flag) {
4421 fUsePWNav = flag;
4422 return;
4423 }
4424 if (!fClosed) {
4425 Error("SetUseParallelWorldNav", "The geometry must be closed first");
4426 return;
4427 }
4428 // Closing the parallel world geometry is mandatory
4430 fUsePWNav = kTRUE;
4431}
4432
4439
4444
4446{
4447 if (fgDefaultUnits == new_value) {
4448 gGeometryLocked = true;
4449 return;
4450 } else if (gGeometryLocked) {
4451 ::Fatal("TGeoManager", "The system of units may only be changed once, \n"
4452 "BEFORE any elements and materials are created! \n"
4453 "Alternatively unlock the default units at own risk.");
4454 } else if (new_value == kG4Units) {
4455 ::Info("TGeoManager", "Changing system of units to Geant4 units (mm, ns, MeV).");
4456 } else if (new_value == kRootUnits) {
4457 ::Info("TGeoManager", "Changing system of units to ROOT units (cm, s, GeV).");
4458 }
4460}
4461
4466
#define SafeDelete(p)
Definition RConfig.hxx:531
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:52
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:84
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define BIT(n)
Definition Rtypes.h:91
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
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:145
@ kNatural
Natural, material-inspired colors (default)
TGeoManager * gGeoManager
static Bool_t gGeometryLocked
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TGeoIdentity * gGeoIdentity
Definition TGeoMatrix.h:538
int nentries
#define gROOT
Definition TROOT.h:426
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:40
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:6007
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:511
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:3787
This class is used in the process of reading and writing the GDML "matrix" tag.
Definition TGDMLMatrix.h:33
Bool_t IsVisTouched() const
Definition TGeoAtt.h:91
void SetVisStreamed(Bool_t vis=kTRUE)
Mark attributes as "streamed to file".
Definition TGeoAtt.cxx:127
void SetVisTouched(Bool_t vis=kTRUE)
Mark visualization attributes as "modified".
Definition TGeoAtt.cxx:137
void SetVisBranch()
Set branch type visibility.
Definition TGeoAtt.cxx:65
Box class.
Definition TGeoBBox.h:18
static TGeoBuilder * Instance(TGeoManager *geom)
Return pointer to singleton.
Strategy object for assigning colors and transparency to geometry volumes.
Class describing rotation + translation.
Definition TGeoMatrix.h:318
Composite shapes are Boolean combinations of two or more shape components.
table of elements
TGeoElement * GetElement(Int_t z)
Base class for chemical elements.
Definition TGeoElement.h:31
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition TGeoMatrix.h:459
An identity transformation.
Definition TGeoMatrix.h:407
A geometry iterator.
Definition TGeoNode.h:249
Int_t GetLevel() const
Definition TGeoNode.h:295
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
static void UnlockGeometry()
Unlock current geometry.
Double_t fPhimax
! highest range for phi cut
Definition TGeoManager.h:68
TGeoVolume * MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
Make in one step a volume pointing to a cone shape with given medium.
void AnimateTracks(Double_t tmin=0, Double_t tmax=5E-8, Int_t nframes=200, Option_t *option="/*")
Draw animation of tracks.
void AddSkinSurface(TGeoSkinSurface *surf)
Add skin surface;.
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
TGeoVolume * MakePcon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nz)
Make in one step a volume pointing to a polycone shape with given medium.
Int_t fRaytraceMode
! Raytrace mode: 0=normal, 1=pass through, 2=transparent
Double_t fVisDensity
Definition TGeoManager.h:74
TGeoNavigator * AddNavigator()
Add a navigator in the list of navigators.
TVirtualGeoTrack * GetTrackOfId(Int_t id) const
Get track with a given ID.
TGeoMaterial * FindDuplicateMaterial(const TGeoMaterial *mat) const
Find if a given material duplicates an existing one.
TGeoVolume * Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Create a new volume by dividing an existing one (GEANT3 like)
TGeoVolume * Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar=0)
Create a volume in GEANT3 style.
Int_t ReplaceVolume(TGeoVolume *vorig, TGeoVolume *vnew)
Replaces all occurrences of VORIG with VNEW in the geometry tree.
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
Int_t GetCurrentNodeId() const
Get the unique ID of the current node.
TGeoPNEntry * GetAlignableEntry(const char *name) const
Retrieves an existing alignable object.
TGeoVolume * fMasterVolume
TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Search the track hierarchy to find the track with the given id.
TObjArray * fArrayPNE
! array of physical node entries
void TestOverlaps(const char *path="")
Geometry overlap checker based on sampling.
static EDefaultUnits GetDefaultUnits()
void RemoveMaterial(Int_t index)
Remove material at given index.
void Matrix(Int_t index, Double_t theta1, Double_t phi1, Double_t theta2, Double_t phi2, Double_t theta3, Double_t phi3)
Create rotation matrix named 'mat<index>'.
TGeoElementTable * GetElementTable()
Returns material table. Creates it if not existing.
Int_t fNtracks
Definition TGeoManager.h:79
THashList * fHashPNE
static Int_t fgVerboseLevel
! Verbosity level for Info messages (no IO).
Definition TGeoManager.h:56
void Init()
Initialize manager class.
Bool_t InitArrayPNE() const
Initialize PNE array for fast access via index and unique-id.
TObjArray * fPhysicalNodes
virtual ULong_t SizeOf(const TGeoNode *node, Option_t *option)
computes the total size in bytes of the branch starting with node.
TObjArray * fUniqueVolumes
static UInt_t fgExportPrecision
! Precision to be used in ASCII exports
Definition TGeoManager.h:60
TObjArray * fRegions
void Node(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot, Bool_t isOnly, Float_t *upar, Int_t npar=0)
Create a node called <name_nr> pointing to the volume called <name> as daughter of the volume called ...
TObjArray * fGShapes
! list of runtime shapes
TGeoVolume * fPaintVolume
! volume currently painted
TGeoSkinSurface * GetSkinSurface(const char *name) const
Get skin surface with a given name;.
void UpdateElements()
Update element flags when geometry is loaded from a file.
TGeoManager()
Default constructor.
void CheckOverlapsBySampling(Double_t ovlp, Int_t npoints)
Check all geometry for illegal overlaps within a limit OVLP.
TVirtualGeoChecker * GetGeomChecker()
Make a default checker if none present. Returns pointer to it.
static TClass * Class()
ConstPropMap_t fProperties
TGeoVolume * MakeTube(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
void CdUp()
Go one level up in geometry.
void DoBackupState()
Backup the current state without affecting the cache stack.
TList * fMaterials
void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)
Check pushes and pulls needed to cross the next boundary with respect to the position given by FindNe...
TObjArray * fVolumes
Int_t * fValuePNEId
TGeoPNEntry * GetAlignableEntryByUID(Int_t uid) const
Retrieves an existing alignable object having a preset UID.
void AddGDMLMatrix(TGDMLMatrix *mat)
Add GDML matrix;.
Bool_t fTimeCut
Definition TGeoManager.h:90
static void SetExportPrecision(UInt_t prec)
void AddBorderSurface(TGeoBorderSurface *surf)
Add border surface;.
void RebuildVoxels()
Rebuild the voxel structures that are flagged as needing rebuild.
void SetClippingShape(TGeoShape *clip)
Set a user-defined shape as clipping for ray tracing.
TGeoVolume * fCurrentVolume
! current volume
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 group volumes providing fast search
TVirtualGeoChecker * fChecker
! current checker
Definition TGeoManager.h:97
Int_t fVisOption
Definition TGeoManager.h:76
static std::mutex fgMutex
! mutex for navigator booking in MT mode
Definition TGeoManager.h:54
Bool_t IsInPhiRange() const
True if current node is in phi range.
virtual Bool_t cd(const char *path="")
Browse the tree of nodes starting from fTopNode according to pathname.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=nullptr)
Returns the deepest node containing fPoint, which must be set a priori.
TGeoMaterial * Material(const char *name, Double_t a, Double_t z, Double_t dens, Int_t uid, Double_t radlen=0, Double_t intlen=0)
Create material with given A, Z and density, having an unique id.
void LocalToMaster(const Double_t *local, Double_t *master) const
Double_t fPhimin
! lowest range for phi cut
Definition TGeoManager.h:67
static Bool_t fgLockNavigators
! Lock existing navigators
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
! flag that the list of physical nodes has to be drawn
Definition TGeoManager.h:91
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=nullptr)
Make an TGeoArb8 volume.
virtual Int_t Export(const char *filename, const char *name="", Option_t *option="vg")
Export this geometry to a file.
TGeoNode * FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE)
Computes as fStep the distance to next daughter of the current volume.
Int_t GetUID(const char *volname) const
Retrieve unique id for a volume name. Return -1 if name not found.
TGeoShape * fClippingShape
! clipping shape for raytracing
TGeoNavigator * GetCurrentNavigator() const
Returns current navigator for the calling thread.
THashList * fHashVolumes
! hash list of volumes providing fast search
TObjArray * fMatrices
Definition TGeoManager.h:99
static Int_t GetNumThreads()
Returns number of threads that were set to use geometry.
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
void ClearNavigators()
Clear all navigators.
Int_t AddTransformation(const TGeoMatrix *matrix)
Add a matrix to the list. Returns index of the matrix in list.
TObjArray * fOpticalSurfaces
TVirtualGeoTrack * GetParentTrackOfId(Int_t id) const
Get parent track with a given ID.
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
UChar_t * fBits
! bits used for voxelization
static Int_t GetMaxLevels()
Return maximum number of levels used in the geometry.
Double_t fTmin
! lower time limit for tracks drawing
Definition TGeoManager.h:69
static Bool_t IsLocked()
Check lock state.
TGeoVolume * fTopVolume
! top level volume in geometry
TGeoVolume * fUserPaintVolume
!
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
! Lock preventing a second geometry to be loaded
Definition TGeoManager.h:55
TGeoVolume * MakePara(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz, Double_t alpha, Double_t theta, Double_t phi)
Make in one step a volume pointing to a parallelepiped shape with given medium.
void TopToMaster(const Double_t *top, Double_t *master) const
Convert coordinates from top volume frame to master.
TObjArray * fShapes
void AddOpticalSurface(TGeoOpticalSurface *optsurf)
Add optical surface;.
static void SetDefaultUnits(EDefaultUnits new_value)
Bool_t fLoopVolumes
! flag volume lists loop
Definition TGeoManager.h:85
Int_t AddMaterial(const TGeoMaterial *material)
Add a material to the list. Returns index of the material in list.
void ClearAttributes()
Reset all attributes to default ones.
static Int_t fgMaxDaughters
! Maximum number of daughters
Definition TGeoManager.h:58
Bool_t fUsePWNav
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
! Max number of threads
Bool_t fIsGeomReading
! flag set when reading geometry
Definition TGeoManager.h:87
TGeoVolume * MakeTorus(const char *name, TGeoMedium *medium, Double_t r, Double_t rmin, Double_t rmax, Double_t phi1=0, Double_t dphi=360)
Make in one step a volume pointing to a torus shape with given medium.
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
TGeoParallelWorld * fParallelWorld
void RegisterMatrix(const TGeoMatrix *matrix)
Register a matrix to the list of matrices.
TVirtualGeoTrack * GetTrack(Int_t index)
static Int_t GetMaxDaughters()
Return maximum number of daughters of a volume used in the geometry.
static void ClearThreadsMap()
Clear the current map of threads.
Int_t AddVolume(TGeoVolume *volume)
Add a volume to the list. Returns index of the volume in list.
TVirtualGeoPainter * fPainter
! current painter
Definition TGeoManager.h:96
void SetVolumeAttribute(const char *name, const char *att, Int_t val)
Set volume attributes in G3 style.
const char * GetPdgName(Int_t pdg) const
Get name for given pdg code;.
void CheckGeometryFull(Int_t ntracks=1000000, Double_t vx=0., Double_t vy=0., Double_t vz=0., Option_t *option="ob")
Geometry checking.
Bool_t fIsNodeSelectable
! flag that nodes are the selected objects in pad rather than volumes
Definition TGeoManager.h:95
TGeoNode * Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)
Make a rectilinear step of length fStep from current point (fPoint) on current direction (fDirection)...
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
Bool_t fActivity
! switch ON/OFF volume activity (default OFF - all volumes active))
Definition TGeoManager.h:94
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
static ThreadsMap_t * fgThreadId
! Thread id's map
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
Definition TGeoManager.h:71
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 to notify that the manager is being destructed
Definition TGeoManager.h:88
void DefaultColors(const TGeoColorScheme *cs=nullptr)
Set default volume colors according to A of material.
Bool_t IsSameLocation() const
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
TGeoVolume * MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz)
Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
Double_t * FindNormal(Bool_t forward=kTRUE)
Computes normal vector to the next surface that will be or was already crossed when propagating on a ...
virtual Int_t GetByteCount(Option_t *option=nullptr)
Get total size of geometry in bytes.
TGeoVolume * MakeGtra(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a twisted trapezoid shape with given medium.
TGeoElementTable * fElementTable
! table of elements
static void SetNavigatorsLock(Bool_t flag)
Set the lock for navigators.
static Int_t fgMaxXtruVert
! Maximum number of Xtru vertices
Definition TGeoManager.h:59
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
Int_t GetVisOption() const
Returns current depth to which geometry is drawn.
static void LockGeometry()
Lock current geometry so that no other geometry can be imported.
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)
Test for shape navigation methods.
static Int_t fgMaxLevel
! Maximum level in geometry
Definition TGeoManager.h:57
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 for using GL matrix
Definition TGeoManager.h:92
void SetVisibility(TObject *obj, Bool_t vis)
Set visibility for a volume.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Bool_t fMatrixReflection
! flag for GL reflections
Definition TGeoManager.h:93
TGeoPNEntry * SetAlignableEntry(const char *unique_name, const char *path, Int_t uid=-1)
Creates an alignable object with unique name corresponding to a path and adds it to the list of align...
void ClearShape(const TGeoShape *shape)
Remove a shape from the list of shapes.
void ModifiedPad() const
Send "Modified" signal to painter.
void BombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new 'bombed' translation vector according current exploded view mode.
TGeoNavigator * fCurrentNavigator
! current navigator
static Bool_t LockDefaultUnits(Bool_t new_value)
Int_t fMaxVisNodes
Definition TGeoManager.h:80
TGeoMedium * GetMedium(const char *medium) const
Search for a named tracking medium. All trailing blanks stripped.
Bool_t InsertPNEId(Int_t uid, Int_t ientry)
Insert a PN entry in the sorted array of indexes.
Int_t fVisLevel
Definition TGeoManager.h:77
void ViewLeaves(Bool_t flag=kTRUE)
Set visualization option (leaves only OR all volumes)
TGeoVolume * MakeCtub(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
Make in one step a volume pointing to a tube segment shape with given medium.
void SetTminTmax(Double_t tmin=0, Double_t tmax=999)
Set time cut interval for drawing tracks.
NavigatorsMap_t fNavigators
! Map between thread id's and navigator arrays
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
Bool_t fPhiCut
Definition TGeoManager.h:89
TGeoNode * CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode)
Cross next boundary and locate within current node The current point must be on the boundary of fCurr...
void DrawTracks(Option_t *option="")
Draw tracks over the geometry, according to option.
void Streamer(TBuffer &) override
Stream an object of class TGeoManager.
void BuildDefaultMaterials()
Now just a shortcut for GetElementTable.
void SetMaxThreads(Int_t nthreads)
Set maximum number of threads for navigation.
TGeoMedium * Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm, Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
Create tracking medium.
void SetExplodedView(Int_t iopt=0)
Set type of exploding view (see TGeoPainter::SetExplodedView())
Double_t Weight(Double_t precision=0.01, Option_t *option="va")
Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
void ClearPhysicalNodes(Bool_t mustdelete=kFALSE)
Clear the current list of physical nodes, so that we can start over with a new list.
static Int_t Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
Parse a string boolean expression and do a syntax check.
void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
Retrieve cartesian and radial bomb factors.
Double_t GetProperty(const char *name, Bool_t *error=nullptr) const
Get a user-defined property.
TObjArray * fTracks
Bool_t IsAnimatingTracks() const
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
static Int_t fgNumThreads
! Number of registered threads
TObjArray * fGDMLMatrices
TGeoPhysicalNode * MakeAlignablePN(const char *name)
Make a physical node from the path pointed by an alignable object with a given name.
void SetCheckedNode(TGeoNode *node)
Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
Int_t AddOverlap(const TNamed *ovlp)
Add an illegal overlap/extrusion to the list.
void CreateThreadData() const
Create thread private data for all geometry objects.
Int_t fNsegments
Definition TGeoManager.h:78
TObjArray * fOverlaps
TGeoNode * SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil=1E-5, const char *g3path="")
shoot npoints randomly in a box of 1E-5 around current point.
Bool_t IsMultiThread() const
TGDMLMatrix * GetGDMLMatrix(const char *name) const
Get GDML matrix with a given name;.
Double_t fTmax
! upper time limit for tracks drawing
Definition TGeoManager.h:70
void InvalidateMeshCaches()
Invalidate mesh caches built by composite shapes.
Int_t TransformVolumeToAssembly(const char *vname)
Transform all volumes named VNAME to assemblies. The volumes must be virtual.
Bool_t fMultiThread
! Flag for multi-threading
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
! Default units in GDML if not explicit in some tags
Definition TGeoManager.h:61
virtual void Edit(Option_t *option="")
Append a pad for this geometry.
Bool_t AddProperty(const char *property, Double_t value)
Add a user-defined property. Returns true if added, false if existing.
~TGeoManager() override
Destructor.
TObjArray * fNodes
Int_t CountNodes(const TGeoVolume *vol=nullptr, Int_t nlevels=10000, Int_t option=0)
Count the total number of nodes starting from a volume, nlevels down.
TGeoMaterial * GetMaterial(const char *matname) const
Search for a named material. All trailing blanks stripped.
void CheckGeometry(Option_t *option="")
Perform last checks on the geometry.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute mouse actions on this manager.
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
Make an assembly of volumes.
Int_t GetBombMode() const
Int_t AddRegion(TGeoRegion *region)
Add a new region of volumes.
void SelectTrackingMedia()
Define different tracking media.
void CdNext()
Do a cd to the node found next by FindNextBoundary.
void CdTop()
Make top level node the current node.
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
Int_t * fKeyPNEId
void DefaultAngles()
Set default angles for a given view.
TGeoMaterial * Mixture(const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nelem, Float_t *wmat, Int_t uid)
Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem materials defined by arrays A,...
std::map< std::thread::id, Int_t > ThreadsMap_t
void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="", Double_t safety=0.)
Classify a given point. See TGeoChecker::CheckPoint().
void SetUseParallelWorldNav(Bool_t flag)
Activate/deactivate usage of parallel world navigation.
void Browse(TBrowser *b) override
Describe how to browse this object.
void Test(Int_t npoints=1000000, Option_t *option="")
Check time of finding "Where am I" for n points.
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
TObjArray * fGVolumes
! list of runtime volumes
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 physical node
void UnbombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new 'unbombed' translation vector according current exploded view mode.
void ResetState()
Reset current state flags.
void RandomPoints(const TGeoVolume *vol, Int_t npoints=10000, Option_t *option="")
Draw random points in the bounding box of a volume.
TGeoParallelWorld * CreateParallelWorld(const char *name)
Create a parallel world for prioritised navigation.
Int_t GetMaterialIndex(const char *matname) const
Return index of named material.
void CdDown(Int_t index)
Make a daughter of current node current.
TGeoNavigatorArray * GetListOfNavigators() const
Get list of navigators for the calling thread.
static Int_t GetMaxXtruVert()
Return maximum number of vertices for an xtru shape used.
void RandomRays(Int_t nrays=1000, Double_t startx=0, Double_t starty=0, Double_t startz=0, const char *target_vol=nullptr, Bool_t check_norm=kFALSE)
Randomly shoot nrays and plot intersections with surfaces for current top node.
void SetAllIndex()
Assigns uid's for all materials,media and matrices.
TObjArray * fSkinSurfaces
void SetVisDensity(Double_t dens=0.01)
Set density threshold.
Int_t fExplodedView
Definition TGeoManager.h:75
Bool_t fClosed
! flag that geometry is closed
Definition TGeoManager.h:84
Int_t GetNsegments() const
Get number of segments approximating circles.
void SetPhiRange(Double_t phimin=0., Double_t phimax=360.)
Set cut phi range.
TGeoHMatrix * fGLMatrix
TVirtualGeoTrack * fCurrentTrack
! current track
Definition TGeoManager.h:81
TObjArray * fPdgNames
void DrawPath(const char *path, Option_t *option="")
Draw current path.
TObjArray * GetListOfPhysicalNodes()
static Int_t ThreadId()
Translates the current thread id to an ordinal number.
Bool_t SetCurrentNavigator(Int_t index)
Switch to another existing navigator for the calling thread.
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
TGeoVolume * MakeHype(const char *name, TGeoMedium *medium, Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeParaboloid(const char *name, TGeoMedium *medium, Double_t rlo, Double_t rhi, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
Int_t AddShape(const TGeoShape *shape)
Add a shape to the list. Returns index of the shape in list.
void SetMaxVisNodes(Int_t maxnodes=10000)
set the maximum number of visible nodes.
void CleanGarbage()
Clean temporary volumes and shapes from garbage collection.
void Voxelize(Option_t *option=nullptr)
Voxelize all non-divided volumes.
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
TGeoBorderSurface * GetBorderSurface(const char *name) const
Get border surface with a given name;.
void ClearThreadData() const
Int_t fSizePNEId
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check all geometry for illegal overlaps within a limit OVLP.
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
Int_t fPdgId[1024]
Definition TGeoManager.h:83
void SortOverlaps()
Sort overlaps by decreasing overlap distance. Extrusions comes first.
TGeoVolume * MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
void RemoveNavigator(const TGeoNavigator *nav)
Clear a single navigator.
void MasterToTop(const Double_t *master, Double_t *top) const
Convert coordinates from master volume frame to top.
Bool_t fStreamVoxels
Definition TGeoManager.h:86
Base class describing materials.
Geometrical transformation package.
Definition TGeoMatrix.h:39
@ kGeoSavePrimitive
Definition TGeoMatrix.h:49
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
@ kMedSavePrimitive
Definition TGeoMedium.h:25
Mixtures of elements.
Int_t GetNelements() const override
TGeoElement * GetElement(Int_t i=0) const override
Retrieve the pointer to the element corresponding to component I.
TGeoNavigator * AddNavigator()
Add a new navigator to the array.
TGeoNavigator * GetCurrentNavigator() const
TGeoNavigator * SetCurrentNavigator(Int_t inav)
Class providing navigation API for TGeo geometries.
void CdUp()
Go one level up in geometry.
void DoBackupState()
Backup the current state without affecting the cache stack.
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
TGeoNode * CrossBoundaryAndLocate(Bool_t downwards, TGeoNode *skipnode)
Cross next boundary and locate within current node The current point must be on the boundary of fCurr...
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
void LocalToMaster(const Double_t *local, Double_t *master) const
void CdNext()
Do a cd to the node found next by FindNextBoundary.
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
Bool_t cd(const char *path="")
Browse the tree of nodes starting from top node according to pathname.
Bool_t IsSameLocation(Double_t x, Double_t y, Double_t z, Bool_t change=kFALSE)
Checks if point (x,y,z) is still in the current node.
void MasterToLocal(const Double_t *master, Double_t *local) const
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
void InspectState() const
Inspects path and all flags for the current state.
TGeoNode * Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)
Make a rectiliniar step of length fStep from current point (fPoint) on current direction (fDirection)...
TGeoVolume * GetCurrentVolume() const
void ResetState()
Reset current state flags.
TGeoNode * FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix=kFALSE)
Computes as fStep the distance to next daughter of the current volume.
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
Bool_t CheckPath(const char *path) const
Check if a geometry path is valid without changing the state of the navigator.
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
void CdTop()
Make top level node the current node.
Int_t GetCurrentNodeId() const
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
void GetBranchOnlys(Int_t *isonly) const
Fill node copy numbers of current branch into an array.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=nullptr)
Returns the deepest node containing fPoint, which must be set a priori.
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
Bool_t IsSamePoint(Double_t x, Double_t y, Double_t z) const
Check if a new point with given coordinates is the same as the last located one.
void CdDown(Int_t index)
Make a daughter of current node current.
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
Double_t * FindNormal(Bool_t forward=kTRUE)
Computes normal vector to the next surface that will be or was already crossed when propagating on a ...
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
A node containing local transformation.
Definition TGeoNode.h:155
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
Bool_t IsOverlapping() const
Definition TGeoNode.h:108
TGeoVolume * GetVolume() const
Definition TGeoNode.h:100
void SaveAttributes(std::ostream &out)
save attributes for this node
Definition TGeoNode.cxx:563
void SetVolume(TGeoVolume *volume)
Definition TGeoNode.h:118
void CheckOverlapsBySampling(Double_t ovlp=0.1, Int_t npoints=1000000)
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition TGeoNode.cxx:198
void CheckShapes()
check for wrong parameters in shapes
Definition TGeoNode.cxx:453
void SetOverlapping(Bool_t flag=kTRUE)
Definition TGeoNode.h:121
Int_t GetNdaughters() const
Definition TGeoNode.h:92
virtual TGeoMatrix * GetMatrix() const =0
void SetVisibility(Bool_t vis=kTRUE) override
Set visibility of the node (obsolete).
Definition TGeoNode.cxx:842
void SetMotherVolume(TGeoVolume *mother)
Definition TGeoNode.h:126
static TClass * Class()
TGeoVolume * GetMotherVolume() const
Definition TGeoNode.h:91
void SetNumber(Int_t number)
Definition TGeoNode.h:119
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition TGeoNode.cxx:246
This is a wrapper class to G4OpticalSurface.
The knowledge of the path to the objects that need to be misaligned is essential since there is no ot...
Base class for a flat parallel geometry.
Bool_t CloseGeometry()
The main geometry must be closed.
void RefreshPhysicalNodes()
Refresh the node pointers and re-voxelize.
Bool_t IsClosed() const
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
Regions are groups of volumes having a common set of user tracking cuts.
Definition TGeoRegion.h:36
Base abstract class for all shapes.
Definition TGeoShape.h:25
virtual Bool_t IsComposite() const
Definition TGeoShape.h:139
Bool_t IsRunTimeShape() const
Definition TGeoShape.h:152
virtual void ComputeBBox()=0
virtual void AfterStreamer()
Definition TGeoShape.h:101
@ kGeoClosedShape
Definition TGeoShape.h:59
TClass * IsA() const override
Definition TGeoShape.h:181
Bool_t TestShapeBit(UInt_t f) const
Definition TGeoShape.h:177
Volume assemblies.
Definition TGeoVolume.h:317
static TGeoVolumeAssembly * MakeAssemblyFromVolume(TGeoVolume *vol)
Make a clone of volume VOL but which is an assembly.
Volume families.
Definition TGeoVolume.h:267
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
Double_t WeightA() const
Analytical computation of the weight.
virtual void ClearThreadData() const
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
void SetNumber(Int_t number)
Definition TGeoVolume.h:246
void SetLineWidth(Width_t lwidth) override
Set the line width.
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:176
Int_t GetRefCount() const
Definition TGeoVolume.h:132
void SortNodes()
sort nodes by decreasing volume of the bounding box.
void Voxelize(Option_t *option)
build the voxels for this volume
Bool_t IsRunTime() const
Definition TGeoVolume.h:110
virtual void CreateThreadData(Int_t nthreads)
virtual Int_t GetByteCount() const
get the total size in bytes for this volume
Bool_t OptimizeVoxels()
Perform an extensive sampling to find which type of voxelization is most efficient.
virtual Bool_t IsVolumeMulti() const
Definition TGeoVolume.h:111
Int_t CountNodes(Int_t nlevels=1000, Int_t option=0)
Count total number of subnodes starting from this volume, nlevels down.
void UnmarkSaved()
Reset SavePrimitive bits.
void SetFinder(TGeoPatternFinder *finder)
Definition TGeoVolume.h:245
Int_t GetNdaughters() const
Definition TGeoVolume.h:363
void Grab()
Definition TGeoVolume.h:137
static TClass * Class()
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:378
void Release()
Definition TGeoVolume.h:138
void FindOverlaps() const
loop all nodes marked as overlaps and find overlapping brothers
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
virtual void SetMedium(TGeoMedium *medium)
Definition TGeoVolume.h:243
TGeoVoxelFinder * GetVoxels() const
Getter for optimization structure.
static TGeoMedium * DummyMedium()
void SetLineColor(Color_t lcolor) override
Set the line color.
Int_t GetNumber() const
Definition TGeoVolume.h:185
TGeoShape * GetShape() const
Definition TGeoVolume.h:191
void SaveAs(const char *filename="", Option_t *option="") const override
Save geometry having this as top volume as a C++ macro.
void SetField(TObject *field)
Definition TGeoVolume.h:232
static void CreateDummyMedium()
Create a dummy medium.
void SetLineStyle(Style_t lstyle) override
Set the line style.
virtual Bool_t IsAssembly() const
Returns true if the volume is an assembly or a scaled assembly.
TGeoVolume * MakeReflectedVolume(const char *newname="") const
Make a copy of this volume which is reflected with respect to XY plane.
virtual Bool_t IsVisible() const
Definition TGeoVolume.h:156
Finder class handling voxels.
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
Definition TGeoXtru.h:22
static TClass * Class()
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
void Clear(Option_t *option="") override
Remove all objects from the list.
TObject * FindObject(const char *name) const override
Find object using its name.
void AddLast(TObject *obj) override
Add object at the end of the list.
Definition THashList.cxx:94
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
virtual const char * GetClassName() const
Definition TKey.h:77
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition TKey.cxx:804
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TNamed()
Definition TNamed.h:38
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
Int_t IndexOf(const TObject *obj) const override
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
virtual void Sort(Int_t upto=kMaxInt)
If objects in array are sortable (i.e.
void Clear(Option_t *option="") override
Remove all objects from the array.
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
Definition TObjArray.h:170
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:90
TObject * Remove(TObject *obj) override
Remove object from array.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
void Add(TObject *obj) override
Definition TObjArray.h:68
Mother of all ROOT objects.
Definition TObject.h:42
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:459
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1081
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:422
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:201
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:986
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:885
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:546
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1095
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1123
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:896
virtual TClass * IsA() const
Definition TObject.h:248
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1069
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:2385
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
Abstract class for geometry checkers.
virtual void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="", Double_t safety=0.)=0
virtual void CheckGeometryFull(Bool_t checkoverlaps=kTRUE, Bool_t checkcrossings=kTRUE, Int_t nrays=10000, const Double_t *vertex=nullptr)=0
virtual void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)=0
virtual void RandomPoints(TGeoVolume *vol, Int_t npoints, Option_t *option)=0
void SetNmeshPoints(Int_t npoints=1000)
Set number of points to be generated on the shape outline when checking for overlaps.
virtual void Test(Int_t npoints, Option_t *option)=0
virtual void CheckBoundaryReference(Int_t icheck=-1)=0
virtual Double_t Weight(Double_t precision=0.01, Option_t *option="v")=0
virtual void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)=0
virtual TGeoNode * SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil, const char *g3path)=0
virtual void SetSelectedNode(TGeoNode *node)=0
virtual void TestOverlaps(const char *path)=0
virtual void RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol=nullptr, Bool_t check_norm=kFALSE)=0
Abstract class for geometry painters.
virtual void SetTopVisible(Bool_t vis=kTRUE)=0
virtual Int_t GetVisLevel() const =0
virtual void DrawPath(const char *path, Option_t *option="")=0
virtual void ModifiedPad(Bool_t update=kFALSE) const =0
virtual void GetViewAngles(Double_t &, Double_t &, Double_t &)
virtual TVirtualGeoTrack * AddTrack(Int_t id, Int_t pdgcode, TObject *particle)=0
virtual void SetExplodedView(Int_t iopt=0)=0
virtual Bool_t IsRaytracing() const =0
virtual void DrawCurrentPoint(Int_t color)=0
virtual void GrabFocus(Int_t nfr=0, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0)=0
virtual void SetVisOption(Int_t option=0)=0
virtual Double_t * GetViewBox()=0
virtual void EstimateCameraMove(Double_t, Double_t, Double_t *, Double_t *)
virtual void SetNsegments(Int_t nseg=20)=0
virtual Int_t CountVisibleNodes()=0
virtual void DefaultAngles()=0
virtual void UnbombTranslation(const Double_t *tr, Double_t *bombtr)=0
virtual void EditGeometry(Option_t *option="")=0
virtual void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const =0
virtual void BombTranslation(const Double_t *tr, Double_t *bombtr)=0
virtual void ExecuteManagerEvent(TGeoManager *geom, Int_t event, Int_t px, Int_t py)=0
virtual void SetBombFactors(Double_t bombx=1.3, Double_t bomby=1.3, Double_t bombz=1.3, Double_t bombr=1.3)=0
Base class for user-defined tracks attached to a geometry.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TH1F * h1
Definition legend1.C:5
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...
Definition TROOT.cxx:581
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:659
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Binary search in an array of n values to locate value.
Definition TMathBase.h:329
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Definition TMath.h:75