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
296// Never destroyed: geometries left to TROOT::EndOfProcessCleanups() are deleted
297// after libGeom's static objects, and the destructor locks this mutex.
298std::mutex &TGeoManager::fgMutex = *new std::mutex;
310
311namespace {
312
313struct TGeoManagerThreadState {
314 const TGeoManager *fManager = nullptr;
315 TGeoNavigator *fNavigator = nullptr;
316 ULong64_t fNavigatorGeneration = 0;
317 Int_t fThreadId = -1;
318 ULong64_t fThreadIdGeneration = 0;
319};
320
321TGeoManagerThreadState &GetGeoManagerThreadState()
322{
323 TTHREAD_TLS(TGeoManagerThreadState) state;
324 return state;
325}
326
327// Thread-local navigator pointers and thread ordinals cannot be reset by the thread deleting a manager.
328// Advancing this generation on destructive/global state transitions makes every thread refresh on its next access.
329std::atomic<ULong64_t> gGeoManagerThreadStateGeneration{1};
330
331void InvalidateGeoManagerThreadState()
332{
333 gGeoManagerThreadStateGeneration.fetch_add(1, std::memory_order_release);
334}
335
336} // namespace
337
338////////////////////////////////////////////////////////////////////////////////
339/// Default constructor.
340
342{
343 if (!fgThreadId)
347 fTmin = 0.;
348 fTmax = 999.;
349 fPhiCut = kFALSE;
350 fPhimin = 0;
351 fPhimax = 360;
356 fClosed = kFALSE;
358 fBits = nullptr;
359 fCurrentNavigator = nullptr;
360 fMaterials = nullptr;
361 fHashPNE = nullptr;
362 fArrayPNE = nullptr;
363 fMatrices = nullptr;
364 fNodes = nullptr;
365 fOverlaps = nullptr;
366 fRegions = nullptr;
367 fNNodes = 0;
368 fMaxVisNodes = 10000;
369 fVolumes = nullptr;
370 fPhysicalNodes = nullptr;
371 fShapes = nullptr;
372 fGVolumes = nullptr;
373 fGShapes = nullptr;
374 fTracks = nullptr;
375 fMedia = nullptr;
376 fNtracks = 0;
377 fNpdg = 0;
378 fPdgNames = nullptr;
379 fGDMLMatrices = nullptr;
380 fOpticalSurfaces = nullptr;
381 fSkinSurfaces = nullptr;
382 fBorderSurfaces = nullptr;
383 memset(fPdgId, 0, 1024 * sizeof(Int_t));
384 // TObjArray *fNavigators; ///<! list of navigators
385 fCurrentTrack = nullptr;
386 fCurrentVolume = nullptr;
387 fTopVolume = nullptr;
388 fTopNode = nullptr;
389 fMasterVolume = nullptr;
390 fPainter = nullptr;
391 fChecker = nullptr;
394 fVisDensity = 0.;
395 fVisLevel = 3;
396 fVisOption = 1;
397 fExplodedView = 0;
398 fNsegments = 20;
399 fNLevel = 0;
400 fUniqueVolumes = nullptr;
401 fClippingShape = nullptr;
404 fGLMatrix = nullptr;
405 fPaintVolume = nullptr;
406 fUserPaintVolume = nullptr;
407 fElementTable = nullptr;
408 fHashVolumes = nullptr;
409 fHashGVolumes = nullptr;
410 fSizePNEId = 0;
411 fNPNEId = 0;
412 fKeyPNEId = nullptr;
413 fValuePNEId = nullptr;
415 fRaytraceMode = 0;
416 fMaxThreads = 0;
418 fParallelWorld = nullptr;
420 } else {
421 Init();
423 gGeoIdentity = new TGeoIdentity("Identity");
425 }
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Constructor.
430
431TGeoManager::TGeoManager(const char *name, const char *title) : TNamed(name, title)
432{
433 if (!gROOT->GetListOfGeometries()->FindObject(this))
434 gROOT->GetListOfGeometries()->Add(this);
435 if (!gROOT->GetListOfBrowsables()->FindObject(this))
436 gROOT->GetListOfBrowsables()->Add(this);
437 Init();
438 gGeoIdentity = new TGeoIdentity("Identity");
440 if (fgVerboseLevel > 0)
441 Info("TGeoManager", "Geometry %s, %s created", GetName(), GetTitle());
442}
443
444////////////////////////////////////////////////////////////////////////////////
445/// Initialize manager class.
446
448{
449 if (gGeoManager) {
450 Warning("Init", "Deleting previous geometry: %s/%s", gGeoManager->GetName(), gGeoManager->GetTitle());
451 delete gGeoManager;
452 if (fgLock)
453 Fatal("Init", "New geometry created while the old one locked !!!");
454 }
455
456 gGeoManager = this;
457 if (!fgThreadId)
460 fTmin = 0.;
461 fTmax = 999.;
462 fPhiCut = kFALSE;
463 fPhimin = 0;
464 fPhimax = 360;
469 fClosed = kFALSE;
471 fBits = new UChar_t[50000]; // max 25000 nodes per volume
472 fCurrentNavigator = nullptr;
473 fHashPNE = new THashList(256, 3);
474 fArrayPNE = nullptr;
475 fMaterials = new THashList(200, 3);
476 fMatrices = new TObjArray(256);
477 fNodes = new TObjArray(30);
478 fOverlaps = new TObjArray(256);
479 fRegions = new TObjArray(256);
480 fNNodes = 0;
481 fMaxVisNodes = 10000;
482 fVolumes = new TObjArray(256);
483 fPhysicalNodes = new TObjArray(256);
484 fShapes = new TObjArray(256);
485 fGVolumes = new TObjArray(256);
486 fGShapes = new TObjArray(256);
487 fTracks = new TObjArray(256);
488 fMedia = new THashList(200, 3);
489 fNtracks = 0;
490 fNpdg = 0;
491 fPdgNames = nullptr;
492 fGDMLMatrices = new TObjArray();
494 fSkinSurfaces = new TObjArray();
496 memset(fPdgId, 0, 1024 * sizeof(Int_t));
497 fCurrentTrack = nullptr;
498 fCurrentVolume = nullptr;
499 fTopVolume = nullptr;
500 fTopNode = nullptr;
501 fMasterVolume = nullptr;
502 fPainter = nullptr;
503 fChecker = nullptr;
506 fVisDensity = 0.;
507 fVisLevel = 3;
508 fVisOption = 1;
509 fExplodedView = 0;
510 fNsegments = 20;
511 fNLevel = 0;
512 fUniqueVolumes = new TObjArray(256);
513 fClippingShape = nullptr;
516 fGLMatrix = new TGeoHMatrix();
517 fPaintVolume = nullptr;
518 fUserPaintVolume = nullptr;
519 fElementTable = nullptr;
520 fHashVolumes = nullptr;
521 fHashGVolumes = nullptr;
522 fSizePNEId = 0;
523 fNPNEId = 0;
524 fKeyPNEId = nullptr;
525 fValuePNEId = nullptr;
527 fRaytraceMode = 0;
528 fMaxThreads = 0;
530 fParallelWorld = nullptr;
532}
533
534////////////////////////////////////////////////////////////////////////////////
535/// Destructor
536
538{
539 if (gGeoManager != this)
540 gGeoManager = this;
542
543 if (gROOT->GetListOfFiles()) { // in case this function is called from TROOT destructor
544 gROOT->GetListOfGeometries()->Remove(this);
545 gROOT->GetListOfBrowsables()->Remove(this);
546 }
547 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
548 // TIter next(brlist);
549 // TBrowser *browser = 0;
550 // while ((browser=(TBrowser*)next())) browser->RecursiveRemove(this);
553 delete TGeoBuilder::Instance(this);
554 if (fBits)
555 delete[] fBits;
558 if (fOverlaps) {
559 fOverlaps->Delete();
561 }
562 if (fRegions) {
563 fRegions->Delete();
565 }
566 if (fMaterials) {
569 }
571 if (fMedia) {
572 fMedia->Delete();
574 }
575 if (fHashVolumes) {
576 fHashVolumes->Clear("nodelete");
578 }
579 if (fHashGVolumes) {
580 fHashGVolumes->Clear("nodelete");
582 }
583 if (fHashPNE) {
584 fHashPNE->Delete();
586 }
587 if (fArrayPNE) {
588 delete fArrayPNE;
589 }
590 if (fVolumes) {
591 fVolumes->Delete();
593 }
594 if (fShapes) {
595 fShapes->Delete();
597 }
598 if (fPhysicalNodes) {
601 }
602 if (fMatrices) {
603 fMatrices->Delete();
605 }
606 if (fTracks) {
607 fTracks->Delete();
609 }
611 if (fPdgNames) {
612 fPdgNames->Delete();
614 }
615 if (fGDMLMatrices) {
618 }
619 if (fOpticalSurfaces) {
622 }
623 if (fSkinSurfaces) {
626 }
627 if (fBorderSurfaces) {
630 }
632 CleanGarbage();
636 if (fSizePNEId) {
637 delete[] fKeyPNEId;
638 delete[] fValuePNEId;
639 }
640 delete fParallelWorld;
642 gGeoIdentity = nullptr;
643 gGeoManager = nullptr;
644}
645
646////////////////////////////////////////////////////////////////////////////////
647/// Add a material to the list. Returns index of the material in list.
648
650{
651 return TGeoBuilder::Instance(this)->AddMaterial((TGeoMaterial *)material);
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Add an illegal overlap/extrusion to the list.
656
658{
660 fOverlaps->Add((TObject *)ovlp);
661 return size;
662}
663
664////////////////////////////////////////////////////////////////////////////////
665/// Add a new region of volumes.
667{
669 fRegions->Add(region);
670 return size;
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// Add a user-defined property. Returns true if added, false if existing.
675
677{
678 auto pos = fProperties.insert(ConstPropMap_t::value_type(property, value));
679 if (!pos.second) {
680 Warning("AddProperty", "Property \"%s\" already exists with value %g", property, (pos.first)->second);
681 return false;
682 }
683 return true;
684}
685
686////////////////////////////////////////////////////////////////////////////////
687/// Get a user-defined property
688
690{
691 auto pos = fProperties.find(property);
692 if (pos == fProperties.end()) {
693 if (error)
694 *error = kTRUE;
695 return 0.;
696 }
697 if (error)
698 *error = kFALSE;
699 return pos->second;
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// Get a user-defined property from a given index
704
706{
707 // This is a quite inefficient way to access map elements, but needed for the GDML writer to
708 if (i >= fProperties.size()) {
709 if (error)
710 *error = kTRUE;
711 return 0.;
712 }
713 size_t pos = 0;
714 auto it = fProperties.begin();
715 while (pos < i) {
716 ++it;
717 ++pos;
718 }
719 if (error)
720 *error = kFALSE;
721 name = (*it).first;
722 return (*it).second;
723}
724
725////////////////////////////////////////////////////////////////////////////////
726/// Add a matrix to the list. Returns index of the matrix in list.
727
732
733////////////////////////////////////////////////////////////////////////////////
734/// Add a shape to the list. Returns index of the shape in list.
735
737{
738 return TGeoBuilder::Instance(this)->AddShape((TGeoShape *)shape);
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// Add a track to the list of tracks. Use this for primaries only. For secondaries,
743/// add them to the parent track. The method create objects that are registered
744/// to the analysis manager but have to be cleaned-up by the user via ClearTracks().
745
747{
749 fTracks->AddAtAndExpand(GetGeomPainter()->AddTrack(id, pdgcode, particle), fNtracks++);
750 return index;
751}
752
753////////////////////////////////////////////////////////////////////////////////
754/// Add a track to the list of tracks
755
762
763////////////////////////////////////////////////////////////////////////////////
764/// Makes a primary track but do not attach it to the list of tracks. The track
765/// can be attached as daughter to another one with TVirtualGeoTrack::AddTrack
766
768{
769 TVirtualGeoTrack *track = GetGeomPainter()->AddTrack(id, pdgcode, particle);
770 return track;
771}
772
773////////////////////////////////////////////////////////////////////////////////
774/// Add a volume to the list. Returns index of the volume in list.
775
777{
778 if (!volume) {
779 Error("AddVolume", "invalid volume");
780 return -1;
781 }
783 if (!uid)
784 uid++;
785 if (!fCurrentVolume) {
786 fCurrentVolume = volume;
787 fUniqueVolumes->AddAtAndExpand(volume, uid);
788 } else {
789 if (!strcmp(volume->GetName(), fCurrentVolume->GetName())) {
790 uid = fCurrentVolume->GetNumber();
791 } else {
792 fCurrentVolume = volume;
793 Int_t olduid = GetUID(volume->GetName());
794 if (olduid < 0) {
795 fUniqueVolumes->AddAtAndExpand(volume, uid);
796 } else {
797 uid = olduid;
798 }
799 }
800 }
801 volume->SetNumber(uid);
802 if (!fHashVolumes) {
803 fHashVolumes = new THashList(256, 3);
804 fHashGVolumes = new THashList(256, 3);
805 }
806 TObjArray *list = fVolumes;
807 if (!volume->GetShape() || volume->IsRunTime() || volume->IsVolumeMulti()) {
808 list = fGVolumes;
809 fHashGVolumes->Add(volume);
810 } else {
811 fHashVolumes->Add(volume);
812 }
813 Int_t index = list->GetEntriesFast();
814 list->AddAtAndExpand(volume, index);
815 return uid;
816}
817
818////////////////////////////////////////////////////////////////////////////////
819/// Add a navigator in the list of navigators. If it is the first one make it
820/// current navigator.
821
823{
824 if (fMultiThread) {
826 fgMutex.lock();
827 }
828 std::thread::id threadId = std::this_thread::get_id();
829 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
830 TGeoNavigatorArray *array = nullptr;
831 if (it != fNavigators.end())
832 array = it->second;
833 else {
834 array = new TGeoNavigatorArray(this);
835 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
836 }
837 TGeoNavigator *nav = array->AddNavigator();
838 if (fClosed)
839 nav->GetCache()->BuildInfoBranch();
840 if (fMultiThread) {
841 auto &state = GetGeoManagerThreadState();
842 state.fManager = this;
843 state.fNavigator = nav;
844 state.fNavigatorGeneration = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
845 fgMutex.unlock();
846 }
847 return nav;
848}
849
850////////////////////////////////////////////////////////////////////////////////
851/// Returns current navigator for the calling thread.
852
854{
855 if (!fMultiThread)
856 return fCurrentNavigator;
857 auto &state = GetGeoManagerThreadState();
858 const auto generation = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
859 if (state.fNavigator && state.fManager == this && state.fNavigatorGeneration == generation)
860 return state.fNavigator;
861
862 std::lock_guard<std::mutex> lock(fgMutex);
863 std::thread::id threadId = std::this_thread::get_id();
864 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
865 if (it == fNavigators.end()) {
866 state.fManager = this;
867 state.fNavigator = nullptr;
868 state.fNavigatorGeneration = generation;
869 return nullptr;
870 }
871 TGeoNavigatorArray *array = it->second;
872 state.fManager = this;
873 state.fNavigator = array->GetCurrentNavigator();
874 state.fNavigatorGeneration = generation;
875 return state.fNavigator;
876}
877
878////////////////////////////////////////////////////////////////////////////////
879/// Get list of navigators for the calling thread.
880
882{
883 std::unique_lock<std::mutex> lock(fgMutex, std::defer_lock);
884 if (fMultiThread)
885 lock.lock();
886 std::thread::id threadId = std::this_thread::get_id();
887 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
888 if (it == fNavigators.end())
889 return nullptr;
890 TGeoNavigatorArray *array = it->second;
891 return array;
892}
893
894////////////////////////////////////////////////////////////////////////////////
895/// Switch to another existing navigator for the calling thread.
896
898{
899 std::unique_lock<std::mutex> lock(fgMutex, std::defer_lock);
900 if (fMultiThread)
901 lock.lock();
902 std::thread::id threadId = std::this_thread::get_id();
903 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
904 if (it == fNavigators.end()) {
905 Error("SetCurrentNavigator", "No navigator defined for this thread\n");
906 std::cout << " thread id: " << threadId << std::endl;
907 return kFALSE;
908 }
909 TGeoNavigatorArray *array = it->second;
911 if (!nav) {
912 Error("SetCurrentNavigator", "Navigator %d not existing for this thread\n", index);
913 std::cout << " thread id: " << threadId << std::endl;
914 return kFALSE;
915 }
916 if (fMultiThread) {
917 auto &state = GetGeoManagerThreadState();
918 state.fManager = this;
919 state.fNavigator = nav;
920 state.fNavigatorGeneration = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
921 } else {
922 fCurrentNavigator = nav;
923 }
924 return kTRUE;
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Set the lock for navigators.
929
934
935////////////////////////////////////////////////////////////////////////////////
936/// Clear all navigators.
937
939{
940 InvalidateGeoManagerThreadState();
941 if (fMultiThread)
942 fgMutex.lock();
943 TGeoNavigatorArray *arr = nullptr;
944 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
945 arr = (*it).second;
946 if (arr)
947 delete arr;
948 }
949 fNavigators.clear();
950 if (fMultiThread)
951 fgMutex.unlock();
952}
953
954////////////////////////////////////////////////////////////////////////////////
955/// Clear a single navigator.
956
958{
959 if (fMultiThread)
960 fgMutex.lock();
961 for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
962 TGeoNavigatorArray *arr = (*it).second;
963 if (arr) {
964 if ((TGeoNavigator *)arr->Remove((TObject *)nav)) {
965 InvalidateGeoManagerThreadState();
966 delete nav;
967 if (!arr->GetEntries())
968 fNavigators.erase(it);
969 if (fMultiThread)
970 fgMutex.unlock();
971 return;
972 }
973 }
974 }
975 Error("Remove navigator", "Navigator %p not found", nav);
976 if (fMultiThread)
977 fgMutex.unlock();
978}
979
980////////////////////////////////////////////////////////////////////////////////
981/// Enable multi-threaded navigation for at most `nthreads` worker threads.
982/// The geometry must be closed and navigation must not be active when this method is called.
983/// This enables ROOT thread safety and prepares the manager and geometry objects for concurrent navigation.
984
986{
987 if (!fClosed) {
988 Error("SetMaxThreads", "Cannot set maximum number of threads before closing the geometry");
989 return;
990 }
991 if (!fMultiThread) {
993 std::thread::id threadId = std::this_thread::get_id();
994 NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
995 if (it != fNavigators.end()) {
996 TGeoNavigatorArray *array = it->second;
997 fNavigators.erase(it);
998 fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
999 }
1000 }
1001 if (fMaxThreads) {
1004 }
1005 InvalidateGeoManagerThreadState();
1006 fMaxThreads = nthreads + 1;
1007 if (fMaxThreads > 0) {
1010 }
1011}
1012
1013////////////////////////////////////////////////////////////////////////////////
1014
1016{
1017 if (!fMaxThreads)
1018 return;
1019 fgMutex.lock();
1020 TIter next(fVolumes);
1021 TGeoVolume *vol;
1022 while ((vol = (TGeoVolume *)next()))
1023 vol->ClearThreadData();
1024 fgMutex.unlock();
1025}
1026
1027////////////////////////////////////////////////////////////////////////////////
1028/// Create thread private data for all geometry objects.
1029
1031{
1032 if (!fMaxThreads)
1033 return;
1034 fgMutex.lock();
1035 TIter next(fVolumes);
1036 TGeoVolume *vol;
1037 while ((vol = (TGeoVolume *)next()))
1039 fgMutex.unlock();
1040}
1041
1042////////////////////////////////////////////////////////////////////////////////
1043/// Clear the current map of threads. This will be filled again by the calling
1044/// threads via ThreadId calls.
1045
1047{
1048 InvalidateGeoManagerThreadState();
1050 return;
1051 fgMutex.lock();
1052 if (!fgThreadId->empty())
1053 fgThreadId->clear();
1054 fgNumThreads = 0;
1055 fgMutex.unlock();
1056}
1057
1058////////////////////////////////////////////////////////////////////////////////
1059/// Translates the current thread id to an ordinal number. This can be used to
1060/// manage data which is specific for a given thread.
1061
1063{
1064 auto &state = GetGeoManagerThreadState();
1065 const auto generation = gGeoManagerThreadStateGeneration.load(std::memory_order_acquire);
1066 if (state.fThreadId > -1 && state.fThreadIdGeneration == generation)
1067 return state.fThreadId;
1069 state.fThreadId = 0;
1070 state.fThreadIdGeneration = generation;
1071 return 0;
1072 }
1073 std::thread::id threadId = std::this_thread::get_id();
1074 std::lock_guard<std::mutex> lock(fgMutex);
1075 TGeoManager::ThreadsMapIt_t it = fgThreadId->find(threadId);
1076 if (it != fgThreadId->end()) {
1077 state.fThreadId = it->second;
1078 state.fThreadIdGeneration = generation;
1079 return state.fThreadId;
1080 }
1081 (*fgThreadId)[threadId] = fgNumThreads;
1082 state.fThreadId = fgNumThreads++;
1083 state.fThreadIdGeneration = generation;
1084 return state.fThreadId;
1085}
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Describe how to browse this object.
1089
1091{
1092 if (!b)
1093 return;
1094 if (fMaterials)
1095 b->Add(fMaterials, "Materials");
1096 if (fMedia)
1097 b->Add(fMedia, "Media");
1098 if (fMatrices)
1099 b->Add(fMatrices, "Local transformations");
1100 if (fOverlaps)
1101 b->Add(fOverlaps, "Illegal overlaps");
1102 if (fTracks)
1103 b->Add(fTracks, "Tracks");
1104 if (fMasterVolume)
1105 b->Add(fMasterVolume, "Master Volume", fMasterVolume->IsVisible());
1106 if (fTopVolume)
1107 b->Add(fTopVolume, "Top Volume", fTopVolume->IsVisible());
1108 if (fTopNode)
1109 b->Add(fTopNode);
1110 TString browserImp(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
1111 TQObject::Connect(browserImp.Data(), "Checked(TObject*,Bool_t)", "TGeoManager", this,
1112 "SetVisibility(TObject*,Bool_t)");
1113}
1114
1115////////////////////////////////////////////////////////////////////////////////
1116/// Append a pad for this geometry.
1117
1123
1124////////////////////////////////////////////////////////////////////////////////
1125/// Set visibility for a volume.
1126
1128{
1129 if (obj->IsA() == TGeoVolume::Class()) {
1130 TGeoVolume *vol = (TGeoVolume *)obj;
1131 vol->SetVisibility(vis);
1132 } else {
1133 if (obj->InheritsFrom(TGeoNode::Class())) {
1134 TGeoNode *node = (TGeoNode *)obj;
1135 node->SetVisibility(vis);
1136 } else
1137 return;
1138 }
1140}
1141
1142////////////////////////////////////////////////////////////////////////////////
1143/// Get the new 'bombed' translation vector according current exploded view mode.
1144
1146{
1147 if (fPainter)
1148 fPainter->BombTranslation(tr, bombtr);
1149 return;
1150}
1151
1152////////////////////////////////////////////////////////////////////////////////
1153/// Get the new 'unbombed' translation vector according current exploded view mode.
1154
1156{
1157 if (fPainter)
1158 fPainter->UnbombTranslation(tr, bombtr);
1159 return;
1160}
1161
1162////////////////////////////////////////////////////////////////////////////////
1163/// Backup the current state without affecting the cache stack.
1164
1169
1170////////////////////////////////////////////////////////////////////////////////
1171/// Restore a backed-up state without affecting the cache stack.
1172
1177
1178////////////////////////////////////////////////////////////////////////////////
1179/// Register a matrix to the list of matrices. It will be cleaned-up at the
1180/// destruction TGeoManager.
1181
1183{
1184 return TGeoBuilder::Instance(this)->RegisterMatrix((TGeoMatrix *)matrix);
1185}
1186
1187////////////////////////////////////////////////////////////////////////////////
1188/// Replaces all occurrences of VORIG with VNEW in the geometry tree. The volume VORIG
1189/// is not replaced from the list of volumes, but all node referencing it will reference
1190/// VNEW instead. Returns number of occurrences changed.
1191
1193{
1194 Int_t nref = 0;
1195 if (!vorig || !vnew)
1196 return nref;
1197 TGeoMedium *morig = vorig->GetMedium();
1198 Bool_t checkmed = kFALSE;
1199 if (morig)
1200 checkmed = kTRUE;
1201 TGeoMedium *mnew = vnew->GetMedium();
1202 // Try to limit the damage produced by incorrect usage.
1203 if (!mnew && !vnew->IsAssembly()) {
1204 Error("ReplaceVolume", "Replacement volume %s has no medium and it is not an assembly", vnew->GetName());
1205 return nref;
1206 }
1207 if (mnew && checkmed) {
1208 if (mnew->GetId() != morig->GetId())
1209 Warning("ReplaceVolume", "Replacement volume %s has different medium than original volume %s", vnew->GetName(),
1210 vorig->GetName());
1211 checkmed = kFALSE;
1212 }
1213
1214 // Medium checking now performed only if replacement is an assembly and old volume a real one.
1215 // Check result is dependent on positioning.
1216 Int_t nvol = fVolumes->GetEntriesFast();
1217 Int_t i, j, nd;
1218 Int_t ierr = 0;
1219 TGeoVolume *vol;
1220 TGeoNode *node;
1221 TGeoVoxelFinder *voxels;
1222 for (i = 0; i < nvol; i++) {
1223 vol = (TGeoVolume *)fVolumes->At(i);
1224 if (!vol)
1225 continue;
1226 if (vol == vorig || vol == vnew)
1227 continue;
1228 nd = vol->GetNdaughters();
1229 for (j = 0; j < nd; j++) {
1230 node = vol->GetNode(j);
1231 if (node->GetVolume() == vorig) {
1232 if (checkmed) {
1233 mnew = node->GetMotherVolume()->GetMedium();
1234 if (mnew && mnew->GetId() != morig->GetId())
1235 ierr++;
1236 }
1237 nref++;
1238 if (node->IsOverlapping()) {
1239 node->SetOverlapping(kFALSE);
1240 Info("ReplaceVolume", "%s replaced with assembly and declared NON-OVERLAPPING!", node->GetName());
1241 }
1242 node->SetVolume(vnew);
1243 voxels = node->GetMotherVolume()->GetVoxels();
1244 if (voxels)
1245 voxels->SetNeedRebuild();
1246 } else {
1247 if (node->GetMotherVolume() == vorig) {
1248 nref++;
1249 node->SetMotherVolume(vnew);
1250 if (node->IsOverlapping()) {
1251 node->SetOverlapping(kFALSE);
1252 Info("ReplaceVolume", "%s inside substitute assembly %s declared NON-OVERLAPPING!", node->GetName(),
1253 vnew->GetName());
1254 }
1255 }
1256 }
1257 }
1258 }
1259 if (ierr)
1260 Warning("ReplaceVolume",
1261 "Volumes should not be replaced with assemblies if they are positioned in containers having a different "
1262 "medium ID.\n %i occurrences for assembly replacing volume %s",
1263 ierr, vorig->GetName());
1264 return nref;
1265}
1266
1267////////////////////////////////////////////////////////////////////////////////
1268/// Rebuild the voxel structures that are flagged as needing rebuild.
1269
1271{
1272 Int_t nvol = fVolumes->GetEntriesFast();
1273 TGeoVolume *vol;
1274 TGeoVoxelFinder *voxels;
1275 for (Int_t i = 0; i < nvol; i++) {
1276 vol = (TGeoVolume *)fVolumes->At(i);
1277 if (!vol)
1278 continue;
1279 voxels = vol->GetVoxels();
1280 if (voxels && voxels->NeedRebuild()) {
1281 voxels->Voxelize();
1282 vol->FindOverlaps(); // after voxelization, check overlaps again
1283 }
1284 }
1285}
1286
1287////////////////////////////////////////////////////////////////////////////////
1288/// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1289
1291{
1292 TGeoVolume *toTransform = FindVolumeFast(vname);
1293 if (!toTransform) {
1294 Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1295 return 0;
1296 }
1297 Int_t index = fVolumes->IndexOf(toTransform);
1298 Int_t count = 0;
1299 Int_t indmax = fVolumes->GetEntries();
1300 Bool_t replace = kTRUE;
1301 TGeoVolume *transformed;
1302 while (index < indmax) {
1303 if (replace) {
1304 replace = kFALSE;
1305 transformed = TGeoVolumeAssembly::MakeAssemblyFromVolume(toTransform);
1306 if (transformed) {
1307 ReplaceVolume(toTransform, transformed);
1308 count++;
1309 } else {
1310 if (toTransform->IsAssembly())
1311 Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1312 if (!toTransform->GetNdaughters())
1313 Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform",
1314 toTransform->GetName());
1315 if (toTransform->IsVolumeMulti())
1316 Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1317 }
1318 }
1319 index++;
1320 if (index >= indmax)
1321 return count;
1322 toTransform = (TGeoVolume *)fVolumes->At(index);
1323 if (!strcmp(toTransform->GetName(), vname))
1324 replace = kTRUE;
1325 }
1326 return count;
1327}
1328
1329////////////////////////////////////////////////////////////////////////////////
1330/// Create a new volume by dividing an existing one (GEANT3 like)
1331///
1332/// Divides MOTHER into NDIV divisions called NAME
1333/// along axis IAXIS starting at coordinate value START
1334/// and having size STEP. The created volumes will have tracking
1335/// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1336/// The behavior of the division operation can be triggered using OPTION :
1337///
1338/// OPTION (case insensitive) :
1339/// - N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1340/// - NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1341/// - S - divide all range with given STEP. NDIV is computed and divisions will be centered
1342/// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1343/// - SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1344
1345TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis, Int_t ndiv, Double_t start,
1346 Double_t step, Int_t numed, Option_t *option)
1347{
1348 return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1349}
1350
1351////////////////////////////////////////////////////////////////////////////////
1352/// Create rotation matrix named 'mat<index>'.
1353///
1354/// - index rotation matrix number
1355/// - theta1 polar angle for axis X
1356/// - phi1 azimuthal angle for axis X
1357/// - theta2 polar angle for axis Y
1358/// - phi2 azimuthal angle for axis Y
1359/// - theta3 polar angle for axis Z
1360/// - phi3 azimuthal angle for axis Z
1361///
1362
1364 Double_t phi3)
1365{
1366 TGeoBuilder::Instance(this)->Matrix(index, theta1, phi1, theta2, phi2, theta3, phi3);
1367}
1368
1369////////////////////////////////////////////////////////////////////////////////
1370/// Create material with given A, Z and density, having an unique id.
1371
1373 Double_t intlen)
1374{
1375 return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1376}
1377
1378////////////////////////////////////////////////////////////////////////////////
1379/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1380/// materials defined by arrays A,Z and WMAT, having an unique id.
1381
1383TGeoManager::Mixture(const char *name, Float_t *a, Float_t *z, Double_t dens, Int_t nelem, Float_t *wmat, Int_t uid)
1384{
1385 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1386}
1387
1388////////////////////////////////////////////////////////////////////////////////
1389/// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1390/// materials defined by arrays A,Z and WMAT, having an unique id.
1391
1393TGeoManager::Mixture(const char *name, Double_t *a, Double_t *z, Double_t dens, Int_t nelem, Double_t *wmat, Int_t uid)
1394{
1395 return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1396}
1397
1398////////////////////////////////////////////////////////////////////////////////
1399/// Create tracking medium
1400///
1401/// - numed tracking medium number assigned
1402/// - name tracking medium name
1403/// - nmat material number
1404/// - isvol sensitive volume flag
1405/// - ifield magnetic field
1406/// - fieldm max. field value (kilogauss)
1407/// - tmaxfd max. angle due to field (deg/step)
1408/// - stemax max. step allowed
1409/// - deemax max. fraction of energy lost in a step
1410/// - epsil tracking precision (cm)
1411/// - stmin min. step due to continuous processes (cm)
1412///
1413/// - ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1414/// - ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1415/// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1416///
1417
1418TGeoMedium *TGeoManager::Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol, Int_t ifield, Double_t fieldm,
1419 Double_t tmaxfd, Double_t stemax, Double_t deemax, Double_t epsil, Double_t stmin)
1420{
1421 return TGeoBuilder::Instance(this)->Medium(name, numed, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil,
1422 stmin);
1423}
1424
1425////////////////////////////////////////////////////////////////////////////////
1426/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1427/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1428/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1429/// In case npar>0, create the volume to be positioned in mother, according
1430/// its actual parameters (gsposp).
1431/// - NAME Volume name
1432/// - NUMBER Copy number of the volume
1433/// - MOTHER Mother volume name
1434/// - X X coord. of the volume in mother ref. sys.
1435/// - Y Y coord. of the volume in mother ref. sys.
1436/// - Z Z coord. of the volume in mother ref. sys.
1437/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1438/// - ISONLY ONLY/MANY flag
1439
1440void TGeoManager::Node(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
1441 Bool_t isOnly, Float_t *upar, Int_t npar)
1442{
1443 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1444}
1445
1446////////////////////////////////////////////////////////////////////////////////
1447/// Create a node called `<name_nr>` pointing to the volume called `<name>`
1448/// as daughter of the volume called `<mother>` (gspos). The relative matrix is
1449/// made of : a translation (x,y,z) and a rotation matrix named `<matIROT>`.
1450/// In case npar>0, create the volume to be positioned in mother, according
1451/// its actual parameters (gsposp).
1452/// - NAME Volume name
1453/// - NUMBER Copy number of the volume
1454/// - MOTHER Mother volume name
1455/// - X X coord. of the volume in mother ref. sys.
1456/// - Y Y coord. of the volume in mother ref. sys.
1457/// - Z Z coord. of the volume in mother ref. sys.
1458/// - IROT Rotation matrix number w.r.t. mother ref. sys.
1459/// - ISONLY ONLY/MANY flag
1460
1461void TGeoManager::Node(const char *name, Int_t nr, const char *mother, Double_t x, Double_t y, Double_t z, Int_t irot,
1462 Bool_t isOnly, Double_t *upar, Int_t npar)
1463{
1464 TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1465}
1466
1467////////////////////////////////////////////////////////////////////////////////
1468/// Create a volume in GEANT3 style.
1469/// - NAME Volume name
1470/// - SHAPE Volume type
1471/// - NMED Tracking medium number
1472/// - NPAR Number of shape parameters
1473/// - UPAR Vector containing shape parameters
1474
1475TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar)
1476{
1477 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1478}
1479
1480////////////////////////////////////////////////////////////////////////////////
1481/// Create a volume in GEANT3 style.
1482/// - NAME Volume name
1483/// - SHAPE Volume type
1484/// - NMED Tracking medium number
1485/// - NPAR Number of shape parameters
1486/// - UPAR Vector containing shape parameters
1487
1488TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed, Double_t *upar, Int_t npar)
1489{
1490 return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1491}
1492
1493////////////////////////////////////////////////////////////////////////////////
1494/// Assigns uid's for all materials,media and matrices.
1495
1497{
1498 Int_t index = 1;
1499 TIter next(fMaterials);
1500 TGeoMaterial *mater;
1501 while ((mater = (TGeoMaterial *)next())) {
1502 mater->SetUniqueID(index++);
1504 }
1505 index = 1;
1506 TIter next1(fMedia);
1507 TGeoMedium *med;
1508 while ((med = (TGeoMedium *)next1())) {
1509 med->SetUniqueID(index++);
1511 }
1512 index = 1;
1513 TIter next2(fShapes);
1514 TGeoShape *shape;
1515 while ((shape = (TGeoShape *)next2())) {
1516 shape->SetUniqueID(index++);
1517 if (shape->IsComposite())
1518 ((TGeoCompositeShape *)shape)->GetBoolNode()->RegisterMatrices();
1519 }
1520
1521 TIter next3(fMatrices);
1522 TGeoMatrix *matrix;
1523 while ((matrix = (TGeoMatrix *)next3())) {
1524 matrix->RegisterYourself();
1525 }
1526 TIter next4(fMatrices);
1527 index = 1;
1528 while ((matrix = (TGeoMatrix *)next4())) {
1529 matrix->SetUniqueID(index++);
1531 }
1532 TIter next5(fVolumes);
1533 TGeoVolume *vol;
1534 while ((vol = (TGeoVolume *)next5()))
1535 vol->UnmarkSaved();
1536}
1537
1538////////////////////////////////////////////////////////////////////////////////
1539/// Reset all attributes to default ones. Default attributes for visualization
1540/// are those defined before closing the geometry.
1541
1543{
1544 if (gPad)
1545 delete gPad;
1546 gPad = nullptr;
1547 SetVisOption(0);
1548 SetVisLevel(3);
1549 SetExplodedView(0);
1551 if (!gStyle)
1552 return;
1553 TIter next(fVolumes);
1554 TGeoVolume *vol = nullptr;
1555 while ((vol = (TGeoVolume *)next())) {
1556 if (!vol->IsVisTouched())
1557 continue;
1558 vol->SetVisTouched(kFALSE);
1559 }
1560}
1561////////////////////////////////////////////////////////////////////////////////
1562/// Closing geometry implies checking the geometry validity, fixing shapes
1563/// with negative parameters (run-time shapes)building the cache manager,
1564/// voxelizing all volumes, counting the total number of physical nodes and
1565/// registering the manager class to the browser.
1566
1568{
1569 if (fClosed) {
1570 Warning("CloseGeometry", "geometry already closed");
1571 return;
1572 }
1573 if (!fMasterVolume) {
1574 Error("CloseGeometry", "you MUST call SetTopVolume() first !");
1575 return;
1576 }
1577 if (!gROOT->GetListOfGeometries()->FindObject(this))
1578 gROOT->GetListOfGeometries()->Add(this);
1579 if (!gROOT->GetListOfBrowsables()->FindObject(this))
1580 gROOT->GetListOfBrowsables()->Add(this);
1581 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1582 // TIter next(brlist);
1583 // TBrowser *browser = 0;
1584 // while ((browser=(TBrowser*)next())) browser->Refresh();
1585 TString opt(option);
1586 opt.ToLower();
1587 // Bool_t dummy = opt.Contains("d");
1588 Bool_t nodeid = opt.Contains("i");
1589 // Create a geometry navigator if not present
1590 TGeoNavigator *nav = nullptr;
1591 Int_t nnavigators = 0;
1592 // Check if the geometry is streamed from file
1593 if (fIsGeomReading) {
1594 if (fgVerboseLevel > 0)
1595 Info("CloseGeometry", "Geometry loaded from file...");
1597 if (!fElementTable)
1599 if (!fTopNode) {
1600 if (!fMasterVolume) {
1601 Error("CloseGeometry", "Master volume not streamed");
1602 return;
1603 }
1605 if (fStreamVoxels && fgVerboseLevel > 0)
1606 Info("CloseGeometry", "Voxelization retrieved from file");
1607 }
1608 // Create a geometry navigator if not present
1609 if (!GetCurrentNavigator())
1611 nnavigators = GetListOfNavigators()->GetEntriesFast();
1612 if (!opt.Contains("nv")) {
1613 Voxelize("ALL");
1614 }
1615 CountLevels();
1616 for (Int_t i = 0; i < nnavigators; i++) {
1617 nav = (TGeoNavigator *)GetListOfNavigators()->At(i);
1618 nav->GetCache()->BuildInfoBranch();
1619 if (nodeid)
1620 nav->GetCache()->BuildIdArray();
1621 }
1622 if (!fHashVolumes) {
1623 Int_t nvol = fVolumes->GetEntriesFast();
1624 Int_t ngvol = fGVolumes->GetEntriesFast();
1625 fHashVolumes = new THashList(nvol + 1, 3);
1626 fHashGVolumes = new THashList(ngvol + 1, 3);
1627 Int_t i;
1628 for (i = 0; i < ngvol; i++)
1630 for (i = 0; i < nvol; i++)
1632 }
1633 fClosed = kTRUE;
1634 if (fParallelWorld) {
1635 if (fgVerboseLevel > 0)
1636 Info("CloseGeometry", "Recreating parallel world %s ...", fParallelWorld->GetName());
1638 }
1639
1640 if (fgVerboseLevel > 0)
1641 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1642 GetTitle());
1643 if (fgVerboseLevel > 0)
1644 Info("CloseGeometry", "----------------modeler ready----------------");
1645 return;
1646 }
1647
1648 // Create a geometry navigator if not present
1649 if (!GetCurrentNavigator())
1651 nnavigators = GetListOfNavigators()->GetEntriesFast();
1653 CheckGeometry();
1654 if (fgVerboseLevel > 0)
1655 Info("CloseGeometry", "Counting nodes...");
1656 fNNodes = CountNodes();
1657 fNLevel = fMasterVolume->CountNodes(1, 3) + 1;
1658 if (fNLevel < 30)
1659 fNLevel = 100;
1660
1661 // BuildIdArray();
1662 // avoid voxelization if requested to speed up geometry startup
1663 if (!opt.Contains("nv")) {
1664 Voxelize("ALL");
1665 } else {
1666 TGeoVolume *vol;
1667 TIter next(fVolumes);
1668 while ((vol = (TGeoVolume *)next())) {
1669 vol->SortNodes();
1670 }
1671 }
1672 if (fgVerboseLevel > 0)
1673 Info("CloseGeometry", "Building cache...");
1674 CountLevels();
1675 for (Int_t i = 0; i < nnavigators; i++) {
1676 nav = (TGeoNavigator *)GetListOfNavigators()->At(i);
1677 nav->GetCache()->BuildInfoBranch();
1678 if (nodeid)
1679 nav->GetCache()->BuildIdArray();
1680 }
1681 fClosed = kTRUE;
1682 if (fgVerboseLevel > 0) {
1683 Info("CloseGeometry", "%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast() - 1,
1684 GetTitle());
1685 Info("CloseGeometry", "----------------modeler ready----------------");
1686 }
1687}
1688
1689////////////////////////////////////////////////////////////////////////////////
1690/// Clear the list of overlaps.
1691
1693{
1694 if (fOverlaps) {
1695 fOverlaps->Delete();
1696 delete fOverlaps;
1697 }
1698 fOverlaps = new TObjArray();
1699}
1700
1701////////////////////////////////////////////////////////////////////////////////
1702/// Remove a shape from the list of shapes.
1703
1705{
1706 if (fShapes->FindObject(shape))
1707 fShapes->Remove((TGeoShape *)shape);
1708 delete shape;
1709}
1710
1711////////////////////////////////////////////////////////////////////////////////
1712/// Clean temporary volumes and shapes from garbage collection.
1713
1715{
1716 if (!fGVolumes && !fGShapes)
1717 return;
1718 Int_t i, nentries;
1719 if (fGVolumes) {
1721 TGeoVolume *vol = nullptr;
1722 for (i = 0; i < nentries; i++) {
1723 vol = (TGeoVolume *)fGVolumes->At(i);
1724 if (vol)
1725 vol->SetFinder(nullptr);
1726 }
1727 fGVolumes->Delete();
1728 delete fGVolumes;
1729 fGVolumes = nullptr;
1730 }
1731 if (fGShapes) {
1732 fGShapes->Delete();
1733 delete fGShapes;
1734 fGShapes = nullptr;
1735 }
1736}
1737
1738////////////////////////////////////////////////////////////////////////////////
1739/// Change current path to point to the node having this id.
1740/// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1741
1743{
1744 GetCurrentNavigator()->CdNode(nodeid);
1745}
1746
1747////////////////////////////////////////////////////////////////////////////////
1748/// Get the unique ID of the current node.
1749
1754
1755////////////////////////////////////////////////////////////////////////////////
1756/// Make top level node the current node. Updates the cache accordingly.
1757/// Determine the overlapping state of current node.
1758
1760{
1762}
1763
1764////////////////////////////////////////////////////////////////////////////////
1765/// Go one level up in geometry. Updates cache accordingly.
1766/// Determine the overlapping state of current node.
1767
1769{
1771}
1772
1773////////////////////////////////////////////////////////////////////////////////
1774/// Make a daughter of current node current. Can be called only with a valid
1775/// daughter index (no check). Updates cache accordingly.
1776
1781
1782////////////////////////////////////////////////////////////////////////////////
1783/// Do a cd to the node found next by FindNextBoundary
1784
1786{
1788}
1789
1790////////////////////////////////////////////////////////////////////////////////
1791/// Browse the tree of nodes starting from fTopNode according to pathname.
1792/// Changes the path accordingly.
1793
1794Bool_t TGeoManager::cd(const char *path)
1795{
1796 return GetCurrentNavigator()->cd(path);
1797}
1798
1799////////////////////////////////////////////////////////////////////////////////
1800/// Check if a geometry path is valid without changing the state of the current navigator.
1801
1802Bool_t TGeoManager::CheckPath(const char *path) const
1803{
1804 return GetCurrentNavigator()->CheckPath(path);
1805}
1806
1807////////////////////////////////////////////////////////////////////////////////
1808/// Convert all reflections in geometry to normal rotations + reflected shapes.
1809
1811{
1812 if (!fTopNode)
1813 return;
1814 if (fgVerboseLevel > 0)
1815 Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1817 TGeoNode *node;
1818 TGeoNodeMatrix *nodematrix;
1819 TGeoMatrix *matrix, *mclone;
1820 TGeoVolume *reflected;
1821 while ((node = next())) {
1822 matrix = node->GetMatrix();
1823 if (matrix->IsReflection()) {
1824 // printf("%s before\n", node->GetName());
1825 // matrix->Print();
1826 mclone = new TGeoCombiTrans(*matrix);
1827 mclone->RegisterYourself();
1828 // Reflect just the rotation component
1829 mclone->ReflectZ(kFALSE, kTRUE);
1830 nodematrix = (TGeoNodeMatrix *)node;
1831 nodematrix->SetMatrix(mclone);
1832 // printf("%s after\n", node->GetName());
1833 // node->GetMatrix()->Print();
1834 reflected = node->GetVolume()->MakeReflectedVolume();
1835 node->SetVolume(reflected);
1836 }
1837 }
1838 if (fgVerboseLevel > 0)
1839 Info("ConvertReflections", "Done");
1840}
1841
1842////////////////////////////////////////////////////////////////////////////////
1843/// Count maximum number of nodes per volume, maximum depth and maximum
1844/// number of xtru vertices.
1845
1847{
1848 if (!fTopNode) {
1849 Error("CountLevels", "Top node not defined.");
1850 return;
1851 }
1853 Bool_t fixrefs = fIsGeomReading && (fMasterVolume->GetRefCount() == 1);
1854 if (fMasterVolume->GetRefCount() > 1)
1856 if (fgVerboseLevel > 1 && fixrefs)
1857 Info("CountLevels", "Fixing volume reference counts");
1858 TGeoNode *node;
1859 Int_t maxlevel = 1;
1860 Int_t maxnodes = fTopVolume->GetNdaughters();
1861 Int_t maxvertices = 1;
1862 while ((node = next())) {
1863 if (fixrefs) {
1864 node->GetVolume()->Grab();
1865 for (Int_t ibit = 10; ibit < 14; ibit++) {
1866 node->SetBit(BIT(ibit + 4), node->TestBit(BIT(ibit)));
1867 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1868 }
1869 }
1870 if (node->GetNdaughters() > maxnodes)
1871 maxnodes = node->GetNdaughters();
1872 if (next.GetLevel() > maxlevel)
1873 maxlevel = next.GetLevel();
1874 if (node->GetVolume()->GetShape()->IsA() == TGeoXtru::Class()) {
1875 TGeoXtru *xtru = (TGeoXtru *)node->GetVolume()->GetShape();
1876 if (xtru->GetNvert() > maxvertices)
1877 maxvertices = xtru->GetNvert();
1878 }
1879 }
1880 fgMaxLevel = maxlevel;
1881 fgMaxDaughters = maxnodes;
1882 fgMaxXtruVert = maxvertices;
1883 if (fgVerboseLevel > 0)
1884 Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1885}
1886
1887////////////////////////////////////////////////////////////////////////////////
1888/// Count the total number of nodes starting from a volume, nlevels down.
1889
1891{
1892 TGeoVolume *top;
1893 if (!vol) {
1894 top = fTopVolume;
1895 } else {
1896 top = (TGeoVolume *)vol;
1897 }
1898 Int_t count = top->CountNodes(nlevels, option);
1899 return count;
1900}
1901
1902////////////////////////////////////////////////////////////////////////////////
1903/// Set default angles for a given view.
1904
1906{
1907 if (fPainter)
1909}
1910
1911////////////////////////////////////////////////////////////////////////////////
1912/// Draw current point in the same view.
1913
1915{
1916 if (fPainter)
1917 fPainter->DrawCurrentPoint(color);
1918}
1919
1920////////////////////////////////////////////////////////////////////////////////
1921/// Draw animation of tracks
1922
1924{
1927 if (tmin < 0 || tmin >= tmax || nframes < 1)
1928 return;
1930 box[0] = box[1] = box[2] = 0;
1931 box[3] = box[4] = box[5] = 100;
1932 Double_t dt = (tmax - tmin) / Double_t(nframes);
1933 Double_t delt = 2E-9;
1934 Double_t t = tmin;
1935 Int_t i, j;
1936 TString opt(option);
1937 Bool_t save = kFALSE, geomanim = kFALSE;
1938 TString fname;
1939 if (opt.Contains("/S"))
1940 save = kTRUE;
1941
1942 if (opt.Contains("/G"))
1943 geomanim = kTRUE;
1944 SetTminTmax(0, 0);
1945 DrawTracks(opt.Data());
1946 Double_t start[6] = {0, 0, 0, 0, 0, 0};
1947 Double_t end[6] = {0, 0, 0, 0, 0, 0};
1948 Double_t dd[6] = {0, 0, 0, 0, 0, 0};
1949 Double_t dlat = 0, dlong = 0, dpsi = 0;
1950 if (geomanim) {
1951 fPainter->EstimateCameraMove(tmin + 5 * dt, tmin + 15 * dt, start, end);
1952 for (i = 0; i < 3; i++) {
1953 start[i + 3] = 20 + 1.3 * start[i + 3];
1954 end[i + 3] = 20 + 0.9 * end[i + 3];
1955 }
1956 for (i = 0; i < 6; i++) {
1957 dd[i] = (end[i] - start[i]) / 10.;
1958 }
1959 memcpy(box, start, 6 * sizeof(Double_t));
1960 fPainter->GetViewAngles(dlong, dlat, dpsi);
1961 dlong = (-206 - dlong) / Double_t(nframes);
1962 dlat = (126 - dlat) / Double_t(nframes);
1963 dpsi = (75 - dpsi) / Double_t(nframes);
1965 }
1966
1967 for (i = 0; i < nframes; i++) {
1968 if (t - delt < 0)
1969 SetTminTmax(t - delt, t);
1970 else
1971 gGeoManager->SetTminTmax(t - delt, t);
1972 if (geomanim) {
1973 for (j = 0; j < 6; j++)
1974 box[j] += dd[j];
1975 fPainter->GrabFocus(1, dlong, dlat, dpsi);
1976 } else {
1977 ModifiedPad();
1978 }
1979 if (save) {
1980 fname = TString::Format("anim%04d.gif", i);
1981 gPad->Print(fname);
1982 }
1983 t += dt;
1984 }
1986}
1987
1988////////////////////////////////////////////////////////////////////////////////
1989/// Draw tracks over the geometry, according to option. By default, only
1990/// primaries are drawn. See TGeoTrack::Draw() for additional options.
1991
1993{
1994 TVirtualGeoTrack *track;
1995 // SetVisLevel(1);
1996 // SetVisOption(1);
1998 for (Int_t i = 0; i < fNtracks; i++) {
1999 track = GetTrack(i);
2000 if (track)
2001 track->Draw(option);
2002 }
2004 ModifiedPad();
2005}
2006
2007////////////////////////////////////////////////////////////////////////////////
2008/// Draw current path
2009
2010void TGeoManager::DrawPath(const char *path, Option_t *option)
2011{
2012 if (!fTopVolume)
2013 return;
2015 GetGeomPainter()->DrawPath(path, option);
2016}
2017
2018////////////////////////////////////////////////////////////////////////////////
2019/// Draw random points in the bounding box of a volume.
2020
2022{
2023 GetGeomChecker()->RandomPoints((TGeoVolume *)vol, npoints, option);
2024}
2025
2026////////////////////////////////////////////////////////////////////////////////
2027/// Check time of finding "Where am I" for n points.
2028
2030{
2031 GetGeomChecker()->Test(npoints, option);
2032}
2033
2034////////////////////////////////////////////////////////////////////////////////
2035/// Geometry overlap checker based on sampling.
2036
2037void TGeoManager::TestOverlaps(const char *path)
2038{
2040}
2041
2042////////////////////////////////////////////////////////////////////////////////
2043/// Fill volume names of current branch into an array.
2044
2046{
2048}
2049
2050////////////////////////////////////////////////////////////////////////////////
2051/// Get name for given pdg code;
2052
2053const char *TGeoManager::GetPdgName(Int_t pdg) const
2054{
2055 static char defaultname[5] = {"XXX"};
2056 if (!fPdgNames || !pdg)
2057 return defaultname;
2058 for (Int_t i = 0; i < fNpdg; i++) {
2059 if (fPdgId[i] == pdg)
2060 return fPdgNames->At(i)->GetName();
2061 }
2062 return defaultname;
2063}
2064
2065////////////////////////////////////////////////////////////////////////////////
2066/// Set a name for a particle having a given pdg.
2067
2068void TGeoManager::SetPdgName(Int_t pdg, const char *name)
2069{
2070 if (!pdg)
2071 return;
2072 if (!fPdgNames) {
2073 fPdgNames = new TObjArray(1024);
2074 }
2075 if (!strcmp(name, GetPdgName(pdg)))
2076 return;
2077 // store pdg name
2078 if (fNpdg > 1023) {
2079 Warning("SetPdgName", "No more than 256 different pdg codes allowed");
2080 return;
2081 }
2082 fPdgId[fNpdg] = pdg;
2083 TNamed *pdgname = new TNamed(name, "");
2084 fPdgNames->AddAtAndExpand(pdgname, fNpdg++);
2085}
2086
2087////////////////////////////////////////////////////////////////////////////////
2088/// Get GDML matrix with a given name;
2089
2091{
2093}
2094
2095////////////////////////////////////////////////////////////////////////////////
2096/// Add GDML matrix;
2098{
2099 if (GetGDMLMatrix(mat->GetName())) {
2100 Error("AddGDMLMatrix", "Matrix %s already added to manager", mat->GetName());
2101 return;
2102 }
2103 fGDMLMatrices->Add(mat);
2104}
2105
2106////////////////////////////////////////////////////////////////////////////////
2107/// Get optical surface with a given name;
2108
2113
2114////////////////////////////////////////////////////////////////////////////////
2115/// Add optical surface;
2117{
2118 if (GetOpticalSurface(optsurf->GetName())) {
2119 Error("AddOpticalSurface", "Surface %s already added to manager", optsurf->GetName());
2120 return;
2121 }
2122 fOpticalSurfaces->Add(optsurf);
2123}
2124
2125////////////////////////////////////////////////////////////////////////////////
2126/// Get skin surface with a given name;
2127
2132
2133////////////////////////////////////////////////////////////////////////////////
2134/// Add skin surface;
2136{
2137 if (GetSkinSurface(surf->GetName())) {
2138 Error("AddSkinSurface", "Surface %s already added to manager", surf->GetName());
2139 return;
2140 }
2141 fSkinSurfaces->Add(surf);
2142}
2143
2144////////////////////////////////////////////////////////////////////////////////
2145/// Get border surface with a given name;
2146
2151
2152////////////////////////////////////////////////////////////////////////////////
2153/// Add border surface;
2155{
2156 if (GetBorderSurface(surf->GetName())) {
2157 Error("AddBorderSurface", "Surface %s already added to manager", surf->GetName());
2158 return;
2159 }
2160 fBorderSurfaces->Add(surf);
2161}
2162
2163////////////////////////////////////////////////////////////////////////////////
2164/// Fill node copy numbers of current branch into an array.
2165
2166void TGeoManager::GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
2167{
2168 GetCurrentNavigator()->GetBranchNumbers(copyNumbers, volumeNumbers);
2169}
2170
2171////////////////////////////////////////////////////////////////////////////////
2172/// Fill node copy numbers of current branch into an array.
2173
2175{
2177}
2178
2179////////////////////////////////////////////////////////////////////////////////
2180/// Retrieve cartesian and radial bomb factors.
2181
2182void TGeoManager::GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
2183{
2184 if (fPainter) {
2185 fPainter->GetBombFactors(bombx, bomby, bombz, bombr);
2186 return;
2187 }
2188 bombx = bomby = bombz = bombr = 1.3;
2189}
2190
2191////////////////////////////////////////////////////////////////////////////////
2192/// Return maximum number of daughters of a volume used in the geometry.
2193
2198
2199////////////////////////////////////////////////////////////////////////////////
2200/// Return maximum number of levels used in the geometry.
2201
2203{
2204 return fgMaxLevel;
2205}
2206
2207////////////////////////////////////////////////////////////////////////////////
2208/// Return maximum number of vertices for an xtru shape used.
2209
2214
2215////////////////////////////////////////////////////////////////////////////////
2216/// Returns number of threads that were set to use geometry.
2217
2222
2223////////////////////////////////////////////////////////////////////////////////
2224/// Return stored current matrix (global matrix of the next touched node).
2225
2227{
2228 if (!GetCurrentNavigator())
2229 return nullptr;
2230 return GetCurrentNavigator()->GetHMatrix();
2231}
2232
2233////////////////////////////////////////////////////////////////////////////////
2234/// Returns current depth to which geometry is drawn.
2235
2237{
2238 return fVisLevel;
2239}
2240
2241////////////////////////////////////////////////////////////////////////////////
2242/// Returns current depth to which geometry is drawn.
2243
2245{
2246 return fVisOption;
2247}
2248
2249////////////////////////////////////////////////////////////////////////////////
2250/// Find level of virtuality of current overlapping node (number of levels
2251/// up having the same tracking media.
2252
2257
2258////////////////////////////////////////////////////////////////////////////////
2259/// Search the track hierarchy to find the track with the
2260/// given id
2261///
2262/// if 'primsFirst' is true, then:
2263/// first tries TGeoManager::GetTrackOfId, then does a
2264/// recursive search if that fails. this would be faster
2265/// if the track is somehow known to be a primary
2266
2268{
2269 TVirtualGeoTrack *trk = nullptr;
2270 trk = GetTrackOfId(id);
2271 if (trk)
2272 return trk;
2273 // need recursive search
2274 TIter next(fTracks);
2275 TVirtualGeoTrack *prim;
2276 while ((prim = (TVirtualGeoTrack *)next())) {
2277 trk = prim->FindTrackWithId(id);
2278 if (trk)
2279 return trk;
2280 }
2281 return nullptr;
2282}
2283
2284////////////////////////////////////////////////////////////////////////////////
2285/// Get track with a given ID.
2286
2288{
2289 TVirtualGeoTrack *track;
2290 for (Int_t i = 0; i < fNtracks; i++) {
2291 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2292 if (track->GetId() == id)
2293 return track;
2294 }
2295 }
2296 return nullptr;
2297}
2298
2299////////////////////////////////////////////////////////////////////////////////
2300/// Get parent track with a given ID.
2301
2303{
2305 while ((track = track->GetMother())) {
2306 if (track->GetId() == id)
2307 return track;
2308 }
2309 return nullptr;
2310}
2311
2312////////////////////////////////////////////////////////////////////////////////
2313/// Get index for track id, -1 if not found.
2314
2316{
2317 TVirtualGeoTrack *track;
2318 for (Int_t i = 0; i < fNtracks; i++) {
2319 if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2320 if (track->GetId() == id)
2321 return i;
2322 }
2323 }
2324 return -1;
2325}
2326
2327////////////////////////////////////////////////////////////////////////////////
2328/// Go upwards the tree until a non-overlapping node
2329
2334
2335////////////////////////////////////////////////////////////////////////////////
2336/// Go upwards the tree until a non-overlapping node
2337
2342
2343////////////////////////////////////////////////////////////////////////////////
2344/// Set default volume colors according to A of material
2345///
2346/// If called with no argument, it uses the new default "natural" scheme
2347/// (including name-based material overrides) and falls back to Z-binned colors.
2348
2350{
2352 const TGeoColorScheme *scheme = cs ? cs : &defaultCS;
2353
2354 TGeoVolume *vol = nullptr;
2355 TIter next(fVolumes);
2356
2357 while ((vol = (TGeoVolume *)next())) {
2358 // Ask scheme for a color (>=0 means "use it")
2359 const Int_t c = scheme->Color(vol);
2360 if (c >= 0)
2361 vol->SetLineColor(c);
2362
2363 // Ask scheme for transparency ([0..100] means "use it")
2364 const Int_t t = scheme->Transparency(vol);
2365 if (t >= 0)
2366 vol->SetTransparency(t);
2367 }
2368 ModifiedPad();
2369}
2370
2371////////////////////////////////////////////////////////////////////////////////
2372/// Compute safe distance from the current point. This represent the distance
2373/// from POINT to the closest boundary.
2374
2376{
2377 return GetCurrentNavigator()->Safety(inside);
2378}
2379
2380////////////////////////////////////////////////////////////////////////////////
2381/// Set volume attributes in G3 style.
2382
2383void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2384{
2385 TGeoVolume *volume;
2386 Bool_t all = kFALSE;
2387 if (strstr(name, "*"))
2388 all = kTRUE;
2389 Int_t ivo = 0;
2390 TIter next(fVolumes);
2391 TString chatt = att;
2392 chatt.ToLower();
2393 while ((volume = (TGeoVolume *)next())) {
2394 if (strcmp(volume->GetName(), name) && !all)
2395 continue;
2396 ivo++;
2397 if (chatt.Contains("colo"))
2398 volume->SetLineColor(val);
2399 if (chatt.Contains("lsty"))
2400 volume->SetLineStyle(val);
2401 if (chatt.Contains("lwid"))
2402 volume->SetLineWidth(val);
2403 if (chatt.Contains("fill"))
2404 volume->SetFillColor(val);
2405 if (chatt.Contains("seen"))
2406 volume->SetVisibility(val);
2407 }
2408 TIter next1(fGVolumes);
2409 while ((volume = (TGeoVolume *)next1())) {
2410 if (strcmp(volume->GetName(), name) && !all)
2411 continue;
2412 ivo++;
2413 if (chatt.Contains("colo"))
2414 volume->SetLineColor(val);
2415 if (chatt.Contains("lsty"))
2416 volume->SetLineStyle(val);
2417 if (chatt.Contains("lwid"))
2418 volume->SetLineWidth(val);
2419 if (chatt.Contains("fill"))
2420 volume->SetFillColor(val);
2421 if (chatt.Contains("seen"))
2422 volume->SetVisibility(val);
2423 }
2424 if (!ivo) {
2425 Warning("SetVolumeAttribute", "volume: %s does not exist", name);
2426 }
2427}
2428
2429////////////////////////////////////////////////////////////////////////////////
2430/// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2431
2433{
2434 if (fPainter)
2435 fPainter->SetBombFactors(bombx, bomby, bombz, bombr);
2436}
2437
2438////////////////////////////////////////////////////////////////////////////////
2439/// Set a user-defined shape as clipping for ray tracing.
2440
2442{
2444 if (shape) {
2445 if (fClippingShape && (fClippingShape != shape))
2447 fClippingShape = shape;
2448 }
2449 painter->SetClippingShape(shape);
2450}
2451
2452////////////////////////////////////////////////////////////////////////////////
2453/// set the maximum number of visible nodes.
2454
2456{
2457 fMaxVisNodes = maxnodes;
2458 if (maxnodes > 0 && fgVerboseLevel > 0)
2459 Info("SetMaxVisNodes", "Automatic visible depth for %d visible nodes", maxnodes);
2460 if (!fPainter)
2461 return;
2463 Int_t level = fPainter->GetVisLevel();
2464 if (level != fVisLevel)
2465 fVisLevel = level;
2466}
2467
2468////////////////////////////////////////////////////////////////////////////////
2469/// make top volume visible on screen
2470
2476
2477////////////////////////////////////////////////////////////////////////////////
2478/// Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
2479
2484
2485////////////////////////////////////////////////////////////////////////////////
2486/// Set the number of points to be generated on the shape outline when checking
2487/// for overlaps.
2488
2490{
2491 GetGeomChecker()->SetNmeshPoints(npoints);
2492}
2493
2494////////////////////////////////////////////////////////////////////////////////
2495/// set drawing mode :
2496/// - option=0 (default) all nodes drawn down to vislevel
2497/// - option=1 leaves and nodes at vislevel drawn
2498/// - option=2 path is drawn
2499/// - option=4 visibility changed
2500
2502{
2503 if ((option >= 0) && (option < 3))
2505 if (fPainter)
2507}
2508
2509////////////////////////////////////////////////////////////////////////////////
2510/// Set visualization option (leaves only OR all volumes)
2511
2513{
2514 if (flag)
2515 SetVisOption(1);
2516 else
2517 SetVisOption(0);
2518}
2519
2520////////////////////////////////////////////////////////////////////////////////
2521/// Set density threshold. Volumes with densities lower than this become
2522/// transparent.
2523
2525{
2526 fVisDensity = density;
2527 if (fPainter)
2529}
2530
2531////////////////////////////////////////////////////////////////////////////////
2532/// set default level down to which visualization is performed
2533
2535{
2536 if (level > 0) {
2537 fVisLevel = level;
2538 fMaxVisNodes = 0;
2539 if (fgVerboseLevel > 0)
2540 Info("SetVisLevel", "Automatic visible depth disabled");
2541 if (fPainter)
2543 } else {
2545 }
2546}
2547
2548////////////////////////////////////////////////////////////////////////////////
2549/// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2550
2552{
2553 fOverlaps->Sort();
2554}
2555
2556////////////////////////////////////////////////////////////////////////////////
2557/// Optimize voxelization type for all volumes. Save best choice in a macro.
2558
2560{
2561 if (!fTopNode) {
2562 Error("OptimizeVoxels", "Geometry must be closed first");
2563 return;
2564 }
2565 std::ofstream out;
2566 TString fname = filename;
2567 if (fname.IsNull())
2568 fname = "tgeovox.C";
2569 out.open(fname, std::ios::out);
2570 if (!out.good()) {
2571 Error("OptimizeVoxels", "cannot open file");
2572 return;
2573 }
2574 // write header
2575 TDatime t;
2576 TString sname(fname);
2577 sname.ReplaceAll(".C", "");
2578 out << sname.Data() << "()" << std::endl;
2579 out << "{" << std::endl;
2580 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2581 out << "//=== Voxel optimization for " << GetTitle() << " geometry" << std::endl;
2582 out << "//===== <run this macro JUST BEFORE closing the geometry>" << std::endl;
2583 out << " TGeoVolume *vol = 0;" << std::endl;
2584 out << " // parse all voxelized volumes" << std::endl;
2585 TGeoVolume *vol = nullptr;
2586 Bool_t cyltype;
2587 TIter next(fVolumes);
2588 while ((vol = (TGeoVolume *)next())) {
2589 if (!vol->GetVoxels())
2590 continue;
2591 out << " vol = gGeoManager->GetVolume(\"" << vol->GetName() << "\");" << std::endl;
2592 cyltype = vol->OptimizeVoxels();
2593 if (cyltype) {
2594 out << " vol->SetCylVoxels();" << std::endl;
2595 } else {
2596 out << " vol->SetCylVoxels(kFALSE);" << std::endl;
2597 }
2598 }
2599 out << "}" << std::endl;
2600 out.close();
2601}
2602////////////////////////////////////////////////////////////////////////////////
2603/// Parse a string boolean expression and do a syntax check. Find top
2604/// level boolean operator and returns its type. Fill the two
2605/// substrings to which this operator applies. The returned integer is :
2606/// - -1 : parse error
2607/// - 0 : no boolean operator
2608/// - 1 : union - represented as '+' in expression
2609/// - 2 : difference (subtraction) - represented as '-' in expression
2610/// - 3 : intersection - represented as '*' in expression.
2611/// Parentheses should be used to avoid ambiguities. For instance :
2612/// - A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2613/// eliminate not needed parentheses
2614
2615Int_t TGeoManager::Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
2616{
2617 TString startstr(expr);
2618 Int_t len = startstr.Length();
2619 Int_t i;
2620 TString e0 = "";
2621 expr3 = "";
2622 // eliminate blanks
2623 for (i = 0; i < len; i++) {
2624 if (startstr(i) == ' ')
2625 continue;
2626 e0 += startstr(i, 1);
2627 }
2628 Int_t level = 0;
2629 Int_t levmin = 999;
2630 Int_t boolop = 0;
2631 Int_t indop = 0;
2632 Int_t iloop = 1;
2633 Int_t lastop = 0;
2634 Int_t lastdp = 0;
2635 Int_t lastpp = 0;
2636 Bool_t foundmat = kFALSE;
2637 // check/eliminate parentheses
2638 while (iloop == 1) {
2639 iloop = 0;
2640 lastop = 0;
2641 lastdp = 0;
2642 lastpp = 0;
2643 len = e0.Length();
2644 for (i = 0; i < len; i++) {
2645 if (e0(i) == '(') {
2646 if (!level)
2647 iloop++;
2648 level++;
2649 continue;
2650 }
2651 if (e0(i) == ')') {
2652 level--;
2653 if (level == 0)
2654 lastpp = i;
2655 continue;
2656 }
2657 if ((e0(i) == '+') || (e0(i) == '-') || (e0(i) == '*')) {
2658 lastop = i;
2659 if (level < levmin) {
2660 levmin = level;
2661 indop = i;
2662 }
2663 continue;
2664 }
2665 if ((e0(i) == ':') && (level == 0)) {
2666 lastdp = i;
2667 continue;
2668 }
2669 }
2670 if (level != 0) {
2671 if (gGeoManager)
2672 gGeoManager->Error("Parse", "parentheses does not match");
2673 return -1;
2674 }
2675 if (iloop == 1 && (e0(0) == '(') && (e0(len - 1) == ')')) {
2676 // eliminate extra parentheses
2677 e0 = e0(1, len - 2);
2678 continue;
2679 }
2680 if (foundmat)
2681 break;
2682 if (((lastop == 0) && (lastdp > 0)) || ((lastpp > 0) && (lastdp > lastpp) && (indop < lastpp))) {
2683 expr3 = e0(lastdp + 1, len - lastdp);
2684 e0 = e0(0, lastdp);
2685 foundmat = kTRUE;
2686 iloop = 1;
2687 continue;
2688 } else
2689 break;
2690 }
2691 // loop expression and search parentheses/operators
2692 levmin = 999;
2693 for (i = 0; i < len; i++) {
2694 if (e0(i) == '(') {
2695 level++;
2696 continue;
2697 }
2698 if (e0(i) == ')') {
2699 level--;
2700 continue;
2701 }
2702 // Take LAST operator at lowest level (revision 28/07/08)
2703 if (level <= levmin) {
2704 if (e0(i) == '+') {
2705 boolop = 1; // union
2706 levmin = level;
2707 indop = i;
2708 }
2709 if (e0(i) == '-') {
2710 boolop = 2; // difference
2711 levmin = level;
2712 indop = i;
2713 }
2714 if (e0(i) == '*') {
2715 boolop = 3; // intersection
2716 levmin = level;
2717 indop = i;
2718 }
2719 }
2720 }
2721 if (indop == 0) {
2722 expr1 = e0;
2723 return indop;
2724 }
2725 expr1 = e0(0, indop);
2726 expr2 = e0(indop + 1, len - indop);
2727 return boolop;
2728}
2729
2730////////////////////////////////////////////////////////////////////////////////
2731/// Save current attributes in a macro
2732
2734{
2735 if (!fTopNode) {
2736 Error("SaveAttributes", "geometry must be closed first\n");
2737 return;
2738 }
2739 std::ofstream out;
2740 TString fname(filename);
2741 if (fname.IsNull())
2742 fname = "tgeoatt.C";
2743 out.open(fname, std::ios::out);
2744 if (!out.good()) {
2745 Error("SaveAttributes", "cannot open file");
2746 return;
2747 }
2748 // write header
2749 TDatime t;
2750 TString sname(fname);
2751 sname.ReplaceAll(".C", "");
2752 out << sname.Data() << "()" << std::endl;
2753 out << "{" << std::endl;
2754 out << "//=== Macro generated by ROOT version " << gROOT->GetVersion() << " : " << t.AsString() << std::endl;
2755 out << "//=== Attributes for " << GetTitle() << " geometry" << std::endl;
2756 out << "//===== <run this macro AFTER loading the geometry in memory>" << std::endl;
2757 // save current top volume
2758 out << " TGeoVolume *top = gGeoManager->GetVolume(\"" << fTopVolume->GetName() << "\");" << std::endl;
2759 out << " TGeoVolume *vol = 0;" << std::endl;
2760 out << " TGeoNode *node = 0;" << std::endl;
2761 out << " // clear all volume attributes and get painter" << std::endl;
2762 out << " gGeoManager->ClearAttributes();" << std::endl;
2763 out << " gGeoManager->GetGeomPainter();" << std::endl;
2764 out << " // set visualization modes and bomb factors" << std::endl;
2765 out << " gGeoManager->SetVisOption(" << GetVisOption() << ");" << std::endl;
2766 out << " gGeoManager->SetVisLevel(" << GetVisLevel() << ");" << std::endl;
2767 out << " gGeoManager->SetExplodedView(" << GetBombMode() << ");" << std::endl;
2768 Double_t bombx, bomby, bombz, bombr;
2769 GetBombFactors(bombx, bomby, bombz, bombr);
2770 out << " gGeoManager->SetBombFactors(" << bombx << "," << bomby << "," << bombz << "," << bombr << ");"
2771 << std::endl;
2772 out << " // iterate volumes container and set new attributes" << std::endl;
2773 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2774 TGeoVolume *vol = nullptr;
2776
2777 TIter next(fVolumes);
2778 while ((vol = (TGeoVolume *)next())) {
2779 vol->SetVisStreamed(kFALSE);
2780 }
2781 out << " // draw top volume with new settings" << std::endl;
2782 out << " top->Draw();" << std::endl;
2783 out << "}" << std::endl;
2784 out.close();
2785}
2786
2787////////////////////////////////////////////////////////////////////////////////
2788/// Returns the deepest node containing fPoint, which must be set a priori.
2789
2791{
2792 return GetCurrentNavigator()->SearchNode(downwards, skipnode);
2793}
2794
2795////////////////////////////////////////////////////////////////////////////////
2796/// Cross next boundary and locate within current node
2797/// The current point must be on the boundary of fCurrentNode.
2798
2800{
2801 return GetCurrentNavigator()->CrossBoundaryAndLocate(downwards, skipnode);
2802}
2803
2804////////////////////////////////////////////////////////////////////////////////
2805/// Compute distance to next boundary within STEPMAX. If no boundary is found,
2806/// propagate current point along current direction with fStep=STEPMAX. Otherwise
2807/// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2808/// node.
2809
2811{
2812 return GetCurrentNavigator()->FindNextBoundaryAndStep(stepmax, compsafe);
2813}
2814
2815////////////////////////////////////////////////////////////////////////////////
2816/// Find distance to next boundary and store it in fStep. Returns node to which this
2817/// boundary belongs. If PATH is specified, compute only distance to the node to which
2818/// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2819/// than this value. STEPMAX represent the step to be made imposed by other reasons than
2820/// geometry (usually physics processes). Therefore in this case this method provides the
2821/// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2822/// fStep with a big number.
2823/// In case frombdr=kTRUE, the isotropic safety is set to zero.
2824///
2825/// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2826/// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2827/// they want this computed for the current point.
2828
2829TGeoNode *TGeoManager::FindNextBoundary(Double_t stepmax, const char *path, Bool_t frombdr)
2830{
2831 // convert current point and direction to local reference
2832 return GetCurrentNavigator()->FindNextBoundary(stepmax, path, frombdr);
2833}
2834
2835////////////////////////////////////////////////////////////////////////////////
2836/// Computes as fStep the distance to next daughter of the current volume.
2837/// The point and direction must be converted in the coordinate system of the current volume.
2838/// The proposed step limit is fStep.
2839
2841{
2842 return GetCurrentNavigator()->FindNextDaughterBoundary(point, dir, idaughter, compmatrix);
2843}
2844
2845////////////////////////////////////////////////////////////////////////////////
2846/// Reset current state flags.
2847
2852
2853////////////////////////////////////////////////////////////////////////////////
2854/// Returns deepest node containing current point.
2855
2857{
2858 return GetCurrentNavigator()->FindNode(safe_start);
2859}
2860
2861////////////////////////////////////////////////////////////////////////////////
2862/// Returns deepest node containing current point.
2863
2868
2869////////////////////////////////////////////////////////////////////////////////
2870/// Computes fast normal to next crossed boundary, assuming that the current point
2871/// is close enough to the boundary. Works only after calling FindNextBoundary.
2872
2877
2878////////////////////////////////////////////////////////////////////////////////
2879/// Computes normal vector to the next surface that will be or was already
2880/// crossed when propagating on a straight line from a given point/direction.
2881/// Returns the normal vector cosines in the MASTER coordinate system. The dot
2882/// product of the normal and the current direction is positive defined.
2883
2885{
2886 return GetCurrentNavigator()->FindNormal(forward);
2887}
2888
2889////////////////////////////////////////////////////////////////////////////////
2890/// Checks if point (x,y,z) is still in the current node.
2891
2896
2897////////////////////////////////////////////////////////////////////////////////
2898/// Check if a new point with given coordinates is the same as the last located one.
2899
2904
2905////////////////////////////////////////////////////////////////////////////////
2906/// True if current node is in phi range
2907
2909{
2910 if (!fPhiCut)
2911 return kTRUE;
2912 const Double_t *origin;
2914 return kFALSE;
2915 origin = ((TGeoBBox *)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2916 Double_t point[3];
2917 LocalToMaster(origin, &point[0]);
2918 Double_t phi = TMath::ATan2(point[1], point[0]) * TMath::RadToDeg();
2919 if (phi < 0)
2920 phi += 360.;
2921 if ((phi >= fPhimin) && (phi <= fPhimax))
2922 return kFALSE;
2923 return kTRUE;
2924}
2925
2926////////////////////////////////////////////////////////////////////////////////
2927/// Initialize current point and current direction vector (normalized)
2928/// in MARS. Return corresponding node.
2929
2931{
2932 return GetCurrentNavigator()->InitTrack(point, dir);
2933}
2934
2935////////////////////////////////////////////////////////////////////////////////
2936/// Initialize current point and current direction vector (normalized)
2937/// in MARS. Return corresponding node.
2938
2940{
2941 return GetCurrentNavigator()->InitTrack(x, y, z, nx, ny, nz);
2942}
2943
2944////////////////////////////////////////////////////////////////////////////////
2945/// Inspects path and all flags for the current state.
2946
2951
2952////////////////////////////////////////////////////////////////////////////////
2953/// Get path to the current node in the form /node0/node1/...
2954
2955const char *TGeoManager::GetPath() const
2956{
2957 return GetCurrentNavigator()->GetPath();
2958}
2959
2960////////////////////////////////////////////////////////////////////////////////
2961/// Get total size of geometry in bytes.
2962
2964{
2965 Int_t count = 0;
2966 TIter next(fVolumes);
2967 TGeoVolume *vol;
2968 while ((vol = (TGeoVolume *)next()))
2969 count += vol->GetByteCount();
2970 TIter next1(fMatrices);
2971 TGeoMatrix *matrix;
2972 while ((matrix = (TGeoMatrix *)next1()))
2973 count += matrix->GetByteCount();
2974 TIter next2(fMaterials);
2975 TGeoMaterial *mat;
2976 while ((mat = (TGeoMaterial *)next2()))
2977 count += mat->GetByteCount();
2978 TIter next3(fMedia);
2979 TGeoMedium *med;
2980 while ((med = (TGeoMedium *)next3()))
2981 count += med->GetByteCount();
2982 if (fgVerboseLevel > 0)
2983 Info("GetByteCount", "Total size of logical tree : %i bytes", count);
2984 return count;
2985}
2986
2987////////////////////////////////////////////////////////////////////////////////
2988/// Make a default painter if none present. Returns pointer to it.
2989
2991{
2992 if (!fPainter) {
2993 const char *kind = nullptr;
2994 if (gPad)
2995 kind = gPad->IsWeb() ? "web" : "root";
2996 else
2997 kind = gEnv->GetValue("GeomPainter.Name", "");
2998
2999 if (!kind || !*kind)
3000 kind = (gROOT->IsWebDisplay() && !gROOT->IsWebDisplayBatch()) ? "web" : "root";
3001
3002 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter", kind)) {
3003 if (h->LoadPlugin() == -1) {
3004 Error("GetGeomPainter", "could not load plugin for %s geo_painter", kind);
3005 return nullptr;
3006 }
3007 fPainter = (TVirtualGeoPainter *)h->ExecPlugin(1, this);
3008 if (!fPainter) {
3009 Error("GetGeomPainter", "could not create %s geo_painter", kind);
3010 return nullptr;
3011 }
3012 } else {
3013 Error("GetGeomPainter", "not found plugin %s for geo_painter", kind);
3014 }
3015 }
3016 return fPainter;
3017}
3018
3019////////////////////////////////////////////////////////////////////////////////
3020/// Make a default checker if none present. Returns pointer to it.
3021
3023{
3024 if (!fChecker) {
3025 if (auto h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoChecker", "root")) {
3026 if (h->LoadPlugin() == -1) {
3027 Error("GetGeomChecker", "could not load plugin for geo_checker");
3028 return nullptr;
3029 }
3030 fChecker = (TVirtualGeoChecker *)h->ExecPlugin(1, this);
3031 if (!fChecker) {
3032 Error("GetGeomChecker", "could not create geo_checker");
3033 return nullptr;
3034 }
3035 } else {
3036 Error("GetGeomChecker", "not found plugin for geo_checker");
3037 }
3038 }
3039 return fChecker;
3040}
3041
3042////////////////////////////////////////////////////////////////////////////////
3043/// Search for a named volume. All trailing blanks stripped.
3044
3046{
3047 TString sname = name;
3048 sname = sname.Strip();
3049 TGeoVolume *vol = (TGeoVolume *)fVolumes->FindObject(sname.Data());
3050 return vol;
3051}
3052
3053////////////////////////////////////////////////////////////////////////////////
3054/// Fast search for a named volume. All trailing blanks stripped.
3055
3057{
3058 if (!fHashVolumes) {
3059 Int_t nvol = fVolumes->GetEntriesFast();
3060 Int_t ngvol = fGVolumes->GetEntriesFast();
3061 fHashVolumes = new THashList(nvol + 1, 3);
3062 fHashGVolumes = new THashList(ngvol + 1, 3);
3063 Int_t i;
3064 for (i = 0; i < ngvol; i++)
3066 for (i = 0; i < nvol; i++)
3068 }
3069 TString sname = name;
3070 sname = sname.Strip();
3071 THashList *list = fHashVolumes;
3072 if (multi)
3073 list = fHashGVolumes;
3074 TGeoVolume *vol = (TGeoVolume *)list->FindObject(sname.Data());
3075 return vol;
3076}
3077
3078////////////////////////////////////////////////////////////////////////////////
3079/// Retrieve unique id for a volume name. Return -1 if name not found.
3080
3081Int_t TGeoManager::GetUID(const char *volname) const
3082{
3083 TGeoManager *geom = (TGeoManager *)this;
3084 TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
3085 if (!vol)
3086 vol = geom->FindVolumeFast(volname, kTRUE);
3087 if (!vol)
3088 return -1;
3089 return vol->GetNumber();
3090}
3091
3092////////////////////////////////////////////////////////////////////////////////
3093/// Find if a given material duplicates an existing one.
3094
3096{
3097 Int_t index = fMaterials->IndexOf(mat);
3098 if (index <= 0)
3099 return nullptr;
3100 TGeoMaterial *other;
3101 for (Int_t i = 0; i < index; i++) {
3102 other = (TGeoMaterial *)fMaterials->At(i);
3103 if (other == mat)
3104 continue;
3105 if (other->IsEq(mat))
3106 return other;
3107 }
3108 return nullptr;
3109}
3110
3111////////////////////////////////////////////////////////////////////////////////
3112/// Search for a named material. All trailing blanks stripped.
3113
3114TGeoMaterial *TGeoManager::GetMaterial(const char *matname) const
3115{
3116 TString sname = matname;
3117 sname = sname.Strip();
3119 return mat;
3120}
3121
3122////////////////////////////////////////////////////////////////////////////////
3123/// Search for a named tracking medium. All trailing blanks stripped.
3124
3125TGeoMedium *TGeoManager::GetMedium(const char *medium) const
3126{
3127 TString sname = medium;
3128 sname = sname.Strip();
3129 TGeoMedium *med = (TGeoMedium *)fMedia->FindObject(sname.Data());
3130 return med;
3131}
3132
3133////////////////////////////////////////////////////////////////////////////////
3134/// Search for a tracking medium with a given ID.
3135
3137{
3138 TIter next(fMedia);
3139 TGeoMedium *med;
3140 while ((med = (TGeoMedium *)next())) {
3141 if (med->GetId() == numed)
3142 return med;
3143 }
3144 return nullptr;
3145}
3146
3147////////////////////////////////////////////////////////////////////////////////
3148/// Return material at position id.
3149
3151{
3152 if (id < 0 || id >= fMaterials->GetSize())
3153 return nullptr;
3154 TGeoMaterial *mat = (TGeoMaterial *)fMaterials->At(id);
3155 return mat;
3156}
3157
3158////////////////////////////////////////////////////////////////////////////////
3159/// Return index of named material.
3160
3161Int_t TGeoManager::GetMaterialIndex(const char *matname) const
3162{
3163 TIter next(fMaterials);
3164 TGeoMaterial *mat;
3165 Int_t id = 0;
3166 TString sname = matname;
3167 sname = sname.Strip();
3168 while ((mat = (TGeoMaterial *)next())) {
3169 if (!strcmp(mat->GetName(), sname.Data()))
3170 return id;
3171 id++;
3172 }
3173 return -1; // fail
3174}
3175
3176////////////////////////////////////////////////////////////////////////////////
3177/// Randomly shoot nrays and plot intersections with surfaces for current
3178/// top node.
3179
3180void TGeoManager::RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol,
3181 Bool_t check_norm)
3182{
3183 GetGeomChecker()->RandomRays(nrays, startx, starty, startz, target_vol, check_norm);
3184}
3185
3186////////////////////////////////////////////////////////////////////////////////
3187/// Remove material at given index.
3188
3190{
3191 TObject *obj = fMaterials->At(index);
3192 if (obj)
3193 fMaterials->Remove(obj);
3194}
3195
3196////////////////////////////////////////////////////////////////////////////////
3197/// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
3198/// from geometry. Deletion has to be managed by users.
3199
3201{
3202 TIter next(fVolumes);
3203 TGeoVolume *vol;
3204 while ((vol = (TGeoVolume *)next()))
3205 vol->SetField(nullptr);
3206}
3207
3208////////////////////////////////////////////////////////////////////////////////
3209/// Change raytracing mode.
3210
3217
3218////////////////////////////////////////////////////////////////////////////////
3219/// Restore the master volume of the geometry.
3220
3222{
3224 return;
3225 if (fMasterVolume)
3227}
3228
3229////////////////////////////////////////////////////////////////////////////////
3230/// Voxelize all non-divided volumes.
3231
3233{
3234 TGeoVolume *vol;
3235 // TGeoVoxelFinder *vox = 0;
3236 if (!fStreamVoxels && fgVerboseLevel > 0)
3237 Info("Voxelize", "Voxelizing...");
3238 // Int_t nentries = fVolumes->GetSize();
3239 TIter next(fVolumes);
3240 while ((vol = (TGeoVolume *)next())) {
3241 if (!fIsGeomReading)
3242 vol->SortNodes();
3243 if (!fStreamVoxels) {
3244 vol->Voxelize(option);
3245 }
3246 if (!fIsGeomReading)
3247 vol->FindOverlaps();
3248 }
3249}
3250
3251////////////////////////////////////////////////////////////////////////////////
3252/// Send "Modified" signal to painter.
3253
3255{
3256 if (!fPainter)
3257 return;
3259}
3260
3261////////////////////////////////////////////////////////////////////////////////
3262/// Make an TGeoArb8 volume.
3263
3265{
3266 return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
3267}
3268
3269////////////////////////////////////////////////////////////////////////////////
3270/// Make in one step a volume pointing to a box shape with given medium.
3271
3273{
3274 return TGeoBuilder::Instance(this)->MakeBox(name, medium, dx, dy, dz);
3275}
3276
3277////////////////////////////////////////////////////////////////////////////////
3278/// Make in one step a volume pointing to a parallelepiped shape with given medium.
3279
3281 Double_t alpha, Double_t theta, Double_t phi)
3282{
3283 return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
3284}
3285
3286////////////////////////////////////////////////////////////////////////////////
3287/// Make in one step a volume pointing to a sphere shape with given medium
3288
3290 Double_t themax, Double_t phimin, Double_t phimax)
3291{
3292 return TGeoBuilder::Instance(this)->MakeSphere(name, medium, rmin, rmax, themin, themax, phimin, phimax);
3293}
3294
3295////////////////////////////////////////////////////////////////////////////////
3296/// Make in one step a volume pointing to a torus shape with given medium.
3297
3299 Double_t phi1, Double_t dphi)
3300{
3301 return TGeoBuilder::Instance(this)->MakeTorus(name, medium, r, rmin, rmax, phi1, dphi);
3302}
3303
3304////////////////////////////////////////////////////////////////////////////////
3305/// Make in one step a volume pointing to a tube shape with given medium.
3306
3308{
3309 return TGeoBuilder::Instance(this)->MakeTube(name, medium, rmin, rmax, dz);
3310}
3311
3312////////////////////////////////////////////////////////////////////////////////
3313/// Make in one step a volume pointing to a tube segment shape with given medium.
3314/// The segment will be from phiStart to phiEnd, the angles are expressed in degree
3315
3317 Double_t phiStart, Double_t phiEnd)
3318{
3319 return TGeoBuilder::Instance(this)->MakeTubs(name, medium, rmin, rmax, dz, phiStart, phiEnd);
3320}
3321
3322////////////////////////////////////////////////////////////////////////////////
3323/// Make in one step a volume pointing to a tube shape with given medium
3324
3326{
3327 return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
3328}
3329
3330////////////////////////////////////////////////////////////////////////////////
3331/// Make in one step a volume pointing to a tube shape with given medium
3332
3334 Double_t stout, Double_t dz)
3335{
3336 return TGeoBuilder::Instance(this)->MakeHype(name, medium, rin, stin, rout, stout, dz);
3337}
3338
3339////////////////////////////////////////////////////////////////////////////////
3340/// Make in one step a volume pointing to a tube shape with given medium
3341
3343{
3344 return TGeoBuilder::Instance(this)->MakeParaboloid(name, medium, rlo, rhi, dz);
3345}
3346
3347////////////////////////////////////////////////////////////////////////////////
3348/// Make in one step a volume pointing to a tube segment shape with given medium
3349
3351 Double_t phi1, Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx,
3352 Double_t ty, Double_t tz)
3353{
3354 return TGeoBuilder::Instance(this)->MakeCtub(name, medium, rmin, rmax, dz, phi1, phi2, lx, ly, lz, tx, ty, tz);
3355}
3356
3357////////////////////////////////////////////////////////////////////////////////
3358/// Make in one step a volume pointing to a cone shape with given medium.
3359
3361 Double_t rmin2, Double_t rmax2)
3362{
3363 return TGeoBuilder::Instance(this)->MakeCone(name, medium, dz, rmin1, rmax1, rmin2, rmax2);
3364}
3365
3366////////////////////////////////////////////////////////////////////////////////
3367/// Make in one step a volume pointing to a cone segment shape with given medium
3368
3370 Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
3371{
3372 return TGeoBuilder::Instance(this)->MakeCons(name, medium, dz, rmin1, rmax1, rmin2, rmax2, phi1, phi2);
3373}
3374
3375////////////////////////////////////////////////////////////////////////////////
3376/// Make in one step a volume pointing to a polycone shape with given medium.
3377
3379{
3380 return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3381}
3382
3383////////////////////////////////////////////////////////////////////////////////
3384/// Make in one step a volume pointing to a polygone shape with given medium.
3385
3386TGeoVolume *
3387TGeoManager::MakePgon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
3388{
3389 return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3390}
3391
3392////////////////////////////////////////////////////////////////////////////////
3393/// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3394
3395TGeoVolume *
3397{
3398 return TGeoBuilder::Instance(this)->MakeTrd1(name, medium, dx1, dx2, dy, dz);
3399}
3400
3401////////////////////////////////////////////////////////////////////////////////
3402/// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3403
3405 Double_t dy2, Double_t dz)
3406{
3407 return TGeoBuilder::Instance(this)->MakeTrd2(name, medium, dx1, dx2, dy1, dy2, dz);
3408}
3409
3410////////////////////////////////////////////////////////////////////////////////
3411/// Make in one step a volume pointing to a trapezoid shape with given medium.
3412
3414 Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
3415 Double_t tl2, Double_t alpha2)
3416{
3417 return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2,
3418 alpha2);
3419}
3420
3421////////////////////////////////////////////////////////////////////////////////
3422/// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3423
3425 Double_t twist, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2,
3426 Double_t bl2, Double_t tl2, Double_t alpha2)
3427{
3428 return TGeoBuilder::Instance(this)->MakeGtra(name, medium, dz, theta, phi, twist, h1, bl1, tl1, alpha1, h2, bl2, tl2,
3429 alpha2);
3430}
3431
3432////////////////////////////////////////////////////////////////////////////////
3433/// Make a TGeoXtru-shaped volume with nz planes
3434
3436{
3437 return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3438}
3439
3440////////////////////////////////////////////////////////////////////////////////
3441/// Creates an alignable object with unique name corresponding to a path
3442/// and adds it to the list of alignables. An optional unique ID can be
3443/// provided, in which case PN entries can be searched fast by uid.
3444
3445TGeoPNEntry *TGeoManager::SetAlignableEntry(const char *unique_name, const char *path, Int_t uid)
3446{
3447 if (!CheckPath(path))
3448 return nullptr;
3449 if (!fHashPNE)
3450 fHashPNE = new THashList(256, 3);
3451 if (!fArrayPNE)
3452 fArrayPNE = new TObjArray(256);
3453 TGeoPNEntry *entry = GetAlignableEntry(unique_name);
3454 if (entry) {
3455 Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3456 return nullptr;
3457 }
3458 entry = new TGeoPNEntry(unique_name, path);
3459 Int_t ientry = fHashPNE->GetSize();
3460 fHashPNE->Add(entry);
3461 fArrayPNE->AddAtAndExpand(entry, ientry);
3462 if (uid >= 0) {
3463 Bool_t added = InsertPNEId(uid, ientry);
3464 if (!added)
3465 Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3466 }
3467 return entry;
3468}
3469
3470////////////////////////////////////////////////////////////////////////////////
3471/// Retrieves an existing alignable object.
3472
3474{
3475 if (!fHashPNE)
3476 return nullptr;
3477 return (TGeoPNEntry *)fHashPNE->FindObject(name);
3478}
3479
3480////////////////////////////////////////////////////////////////////////////////
3481/// Retrieves an existing alignable object at a given index.
3482
3484{
3485 if (!fArrayPNE && !InitArrayPNE())
3486 return nullptr;
3487 return (TGeoPNEntry *)fArrayPNE->At(index);
3488}
3489
3490////////////////////////////////////////////////////////////////////////////////
3491/// Retrieves an existing alignable object having a preset UID.
3492
3494{
3495 if (!fNPNEId || (!fArrayPNE && !InitArrayPNE()))
3496 return nullptr;
3498 if (index < 0 || fKeyPNEId[index] != uid)
3499 return nullptr;
3501}
3502
3503////////////////////////////////////////////////////////////////////////////////
3504/// Retrieves number of PN entries with or without UID.
3505
3507{
3508 if (!fHashPNE)
3509 return 0;
3510 if (with_uid)
3511 return fNPNEId;
3512 return fHashPNE->GetSize();
3513}
3514
3515////////////////////////////////////////////////////////////////////////////////
3516/// Insert a PN entry in the sorted array of indexes.
3517
3519{
3520 if (!fSizePNEId) {
3521 // Create the arrays.
3522 fSizePNEId = 128;
3523 fKeyPNEId = new Int_t[fSizePNEId];
3524 memset(fKeyPNEId, 0, fSizePNEId * sizeof(Int_t));
3526 memset(fValuePNEId, 0, fSizePNEId * sizeof(Int_t));
3527 fKeyPNEId[fNPNEId] = uid;
3528 fValuePNEId[fNPNEId++] = ientry;
3529 return kTRUE;
3530 }
3531 // Search id in the existing array and return false if it already exists.
3533 if (index > 0 && fKeyPNEId[index] == uid)
3534 return kFALSE;
3535 // Resize the arrays and insert the value
3536 Bool_t resize = (fNPNEId == fSizePNEId) ? kTRUE : kFALSE;
3537 if (resize) {
3538 // Double the size of the array
3539 fSizePNEId *= 2;
3540 // Create new arrays of keys and values
3541 Int_t *keys = new Int_t[fSizePNEId];
3542 memset(keys, 0, fSizePNEId * sizeof(Int_t));
3543 Int_t *values = new Int_t[fSizePNEId];
3544 memset(values, 0, fSizePNEId * sizeof(Int_t));
3545 // Copy all keys<uid in the new keys array (0 to index)
3546 memcpy(keys, fKeyPNEId, (index + 1) * sizeof(Int_t));
3547 memcpy(values, fValuePNEId, (index + 1) * sizeof(Int_t));
3548 // Insert current key at index+1
3549 keys[index + 1] = uid;
3550 values[index + 1] = ientry;
3551 // Copy all remaining keys from the old to new array
3552 memcpy(&keys[index + 2], &fKeyPNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3553 memcpy(&values[index + 2], &fValuePNEId[index + 1], (fNPNEId - index - 1) * sizeof(Int_t));
3554 delete[] fKeyPNEId;
3555 fKeyPNEId = keys;
3556 delete[] fValuePNEId;
3557 fValuePNEId = values;
3558 fNPNEId++;
3559 return kTRUE;
3560 }
3561 // Insert the value in the existing arrays
3562 Int_t i;
3563 for (i = fNPNEId - 1; i > index; i--) {
3564 fKeyPNEId[i + 1] = fKeyPNEId[i];
3565 fValuePNEId[i + 1] = fValuePNEId[i];
3566 }
3567 fKeyPNEId[index + 1] = uid;
3568 fValuePNEId[index + 1] = ientry;
3569 fNPNEId++;
3570 return kTRUE;
3571}
3572
3573////////////////////////////////////////////////////////////////////////////////
3574/// Make a physical node from the path pointed by an alignable object with a given name.
3575
3577{
3579 if (!entry) {
3580 Error("MakeAlignablePN", "No alignable object named %s found !", name);
3581 return nullptr;
3582 }
3583 return MakeAlignablePN(entry);
3584}
3585
3586////////////////////////////////////////////////////////////////////////////////
3587/// Make a physical node from the path pointed by a given alignable object.
3588
3590{
3591 if (!entry) {
3592 Error("MakeAlignablePN", "No alignable object specified !");
3593 return nullptr;
3594 }
3595 const char *path = entry->GetTitle();
3596 if (!cd(path)) {
3597 Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s", entry->GetName(), path);
3598 return nullptr;
3599 }
3600 TGeoPhysicalNode *node = MakePhysicalNode(path);
3601 entry->SetPhysicalNode(node);
3602 return node;
3603}
3604
3605////////////////////////////////////////////////////////////////////////////////
3606/// Makes a physical node corresponding to a path. If PATH is not specified,
3607/// makes physical node matching current modeller state.
3608
3610{
3611 TGeoPhysicalNode *node;
3612 if (path) {
3613 if (!CheckPath(path)) {
3614 Error("MakePhysicalNode", "path: %s not valid", path);
3615 return nullptr;
3616 }
3617 node = new TGeoPhysicalNode(path);
3618 } else {
3619 node = new TGeoPhysicalNode(GetPath());
3620 }
3621 fPhysicalNodes->Add(node);
3622 return node;
3623}
3624
3625////////////////////////////////////////////////////////////////////////////////
3626/// Refresh physical nodes to reflect the actual geometry paths after alignment
3627/// was applied. Optionally locks physical nodes (default).
3628
3630{
3632 TGeoPhysicalNode *pn;
3633 while ((pn = (TGeoPhysicalNode *)next()))
3634 pn->Refresh();
3637 if (lock)
3638 LockGeometry();
3639}
3640
3641////////////////////////////////////////////////////////////////////////////////
3642/// Clear the current list of physical nodes, so that we can start over with a new list.
3643/// If MUSTDELETE is true, delete previous nodes.
3644
3646{
3647 if (mustdelete)
3649 else
3651}
3652
3653////////////////////////////////////////////////////////////////////////////////
3654/// Make an assembly of volumes.
3655
3660
3661////////////////////////////////////////////////////////////////////////////////
3662/// Make a TGeoVolumeMulti handling a list of volumes.
3663
3665{
3666 return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3667}
3668
3669////////////////////////////////////////////////////////////////////////////////
3670/// Set type of exploding view (see TGeoPainter::SetExplodedView())
3671
3673{
3674 if ((ibomb >= 0) && (ibomb < 4))
3675 fExplodedView = ibomb;
3676 if (fPainter)
3677 fPainter->SetExplodedView(ibomb);
3678}
3679
3680////////////////////////////////////////////////////////////////////////////////
3681/// Set cut phi range
3682
3684{
3685 if ((phimin == 0) && (phimax == 360)) {
3686 fPhiCut = kFALSE;
3687 return;
3688 }
3689 fPhiCut = kTRUE;
3690 fPhimin = phimin;
3691 fPhimax = phimax;
3692}
3693
3694////////////////////////////////////////////////////////////////////////////////
3695/// Set number of segments for approximating circles in drawing.
3696
3698{
3699 if (fNsegments == nseg)
3700 return;
3701 if (nseg > 2)
3702 fNsegments = nseg;
3703 if (fPainter)
3704 fPainter->SetNsegments(nseg);
3706}
3707
3708////////////////////////////////////////////////////////////////////////////////
3709/// Get number of segments approximating circles
3710
3712{
3713 return fNsegments;
3714}
3715
3716////////////////////////////////////////////////////////////////////////////////
3717/// Invalidate mesh caches built by composite shapes
3718
3720{
3721 TIter next_shape(fShapes);
3722 TGeoShape *shape;
3723 while ((shape = (TGeoShape *)next_shape())) {
3724 if (shape->IsComposite())
3725 ((TGeoCompositeShape *)shape)->InvalidateMeshCaches();
3726 }
3727}
3728
3729////////////////////////////////////////////////////////////////////////////////
3730/// Now just a shortcut for GetElementTable.
3731
3737
3738////////////////////////////////////////////////////////////////////////////////
3739/// Returns material table. Creates it if not existing.
3740
3747
3748////////////////////////////////////////////////////////////////////////////////
3749/// Make a rectilinear step of length fStep from current point (fPoint) on current
3750/// direction (fDirection). If the step is imposed by geometry, is_geom flag
3751/// must be true (default). The cross flag specifies if the boundary should be
3752/// crossed in case of a geometry step (default true). Returns new node after step.
3753/// Set also on boundary condition.
3754
3756{
3757 return GetCurrentNavigator()->Step(is_geom, cross);
3758}
3759
3760////////////////////////////////////////////////////////////////////////////////
3761/// shoot npoints randomly in a box of 1E-5 around current point.
3762/// return minimum distance to points outside
3763
3764TGeoNode *TGeoManager::SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil, const char *g3path)
3765{
3766 return GetGeomChecker()->SamplePoints(npoints, dist, epsil, g3path);
3767}
3768
3769////////////////////////////////////////////////////////////////////////////////
3770/// Set the top volume and corresponding node as starting point of the geometry.
3771
3773{
3774 if (fTopVolume == vol)
3775 return;
3776
3777 TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3778 TIter next(brlist);
3779 TBrowser *browser = nullptr;
3780
3781 if (fTopVolume)
3782 fTopVolume->SetTitle("");
3783 fTopVolume = vol;
3784 vol->SetTitle("Top volume");
3785 if (fTopNode) {
3786 TGeoNode *topn = fTopNode;
3787 fTopNode = nullptr;
3788 while ((browser = (TBrowser *)next()))
3789 browser->RecursiveRemove(topn);
3790 delete topn;
3791 } else {
3792 fMasterVolume = vol;
3795 if (fgVerboseLevel > 0)
3796 Info("SetTopVolume", "Top volume is %s. Master volume is %s", fTopVolume->GetName(), fMasterVolume->GetName());
3797 }
3798 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3799 // fCurrentMatrix->Print();
3801 fTopNode->SetName(TString::Format("%s_1", vol->GetName()));
3802 fTopNode->SetNumber(1);
3803 fTopNode->SetTitle("Top logical node");
3804 fNodes->AddAt(fTopNode, 0);
3805 if (!GetCurrentNavigator()) {
3807 return;
3808 }
3809 Int_t nnavigators = 0;
3811 if (!arr)
3812 return;
3813 nnavigators = arr->GetEntriesFast();
3814 for (Int_t i = 0; i < nnavigators; i++) {
3815 TGeoNavigator *nav = (TGeoNavigator *)arr->At(i);
3816 nav->ResetAll();
3817 if (fClosed)
3818 nav->GetCache()->BuildInfoBranch();
3819 }
3820}
3821
3822////////////////////////////////////////////////////////////////////////////////
3823/// Define different tracking media.
3824
3826{
3827 /*
3828 Int_t nmat = fMaterials->GetSize();
3829 if (!nmat) {printf(" No materials !\n"); return;}
3830 Int_t *media = new Int_t[nmat];
3831 memset(media, 0, nmat*sizeof(Int_t));
3832 Int_t imedia = 1;
3833 TGeoMaterial *mat, *matref;
3834 mat = (TGeoMaterial*)fMaterials->At(0);
3835 if (mat->GetMedia()) {
3836 for (Int_t i=0; i<nmat; i++) {
3837 mat = (TGeoMaterial*)fMaterials->At(i);
3838 mat->Print();
3839 }
3840 return;
3841 }
3842 mat->SetMedia(imedia);
3843 media[0] = imedia++;
3844 mat->Print();
3845 for (Int_t i=0; i<nmat; i++) {
3846 mat = (TGeoMaterial*)fMaterials->At(i);
3847 for (Int_t j=0; j<i; j++) {
3848 matref = (TGeoMaterial*)fMaterials->At(j);
3849 if (mat->IsEq(matref)) {
3850 mat->SetMedia(media[j]);
3851 break;
3852 }
3853 if (j==(i-1)) {
3854 // different material
3855 mat->SetMedia(imedia);
3856 media[i] = imedia++;
3857 mat->Print();
3858 }
3859 }
3860 }
3861 */
3862}
3863
3864////////////////////////////////////////////////////////////////////////////////
3865/// Check pushes and pulls needed to cross the next boundary with respect to the
3866/// position given by FindNextBoundary. If radius is not mentioned the full bounding
3867/// box will be sampled.
3868
3870{
3871 GetGeomChecker()->CheckBoundaryErrors(ntracks, radius);
3872}
3873
3874////////////////////////////////////////////////////////////////////////////////
3875/// Check the boundary errors reference file created by CheckBoundaryErrors method.
3876/// The shape for which the crossing failed is drawn with the starting point in red
3877/// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3878
3883
3884////////////////////////////////////////////////////////////////////////////////
3885/// Classify a given point. See TGeoChecker::CheckPoint().
3886
3891
3892////////////////////////////////////////////////////////////////////////////////
3893/// Test for shape navigation methods. Summary for test numbers:
3894/// - 1: DistFromInside/Outside. Sample points inside the shape. Generate
3895/// directions randomly in cos(theta). Compute DistFromInside and move the
3896/// point with bigger distance. Compute DistFromOutside back from new point.
3897/// Plot d-(d1+d2)
3898///
3899
3901{
3902 GetGeomChecker()->CheckShape(shape, testNo, nsamples, option);
3903}
3904
3905////////////////////////////////////////////////////////////////////////////////
3906/// Geometry checking.
3907/// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3908/// - if option contains 'b': Optional boundary crossing check + timing per volume.
3909///
3910/// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3911/// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3912/// be called for the suspicious volumes.
3913///
3914/// STAGE 2: normal overlap checking using the shapes mesh - fills the list of
3915/// overlaps.
3916///
3917/// STAGE 3: shooting NRAYS rays from VERTEX and counting the total number of
3918/// crossings per volume (rays propagated from boundary to boundary until
3919/// geometry exit). Timing computed and results stored in a histo.
3920///
3921/// STAGE 4: shooting 1 mil. random rays inside EACH volume and calling
3922/// FindNextBoundary() + Safety() for each call. The timing is normalized by the
3923/// number of crossings computed at stage 2 and presented as percentage.
3924/// One can get a picture on which are the most "burned" volumes during
3925/// transportation from geometry point of view. Another plot of the timing per
3926/// volume vs. number of daughters is produced.
3927
3929{
3930 TString opt(option);
3931 opt.ToLower();
3932 if (!opt.Length()) {
3933 Error("CheckGeometryFull", "The option string must contain a letter. See method documentation.");
3934 return;
3935 }
3936 Bool_t checkoverlaps = opt.Contains("o");
3937 Bool_t checkcrossings = opt.Contains("b");
3938 Double_t vertex[3];
3939 vertex[0] = vx;
3940 vertex[1] = vy;
3941 vertex[2] = vz;
3942 GetGeomChecker()->CheckGeometryFull(checkoverlaps, checkcrossings, ntracks, vertex);
3943}
3944
3945////////////////////////////////////////////////////////////////////////////////
3946/// Perform last checks on the geometry
3947
3949{
3950 if (fgVerboseLevel > 0)
3951 Info("CheckGeometry", "Fixing runtime shapes...");
3952 TIter next(fShapes);
3953 TIter nextv(fVolumes);
3954 TGeoShape *shape;
3955 TGeoVolume *vol;
3956 Bool_t has_runtime = kFALSE;
3957 while ((shape = (TGeoShape *)next())) {
3958 if (shape->IsRunTimeShape()) {
3959 has_runtime = kTRUE;
3960 }
3961 if (fIsGeomReading)
3962 shape->AfterStreamer();
3965 shape->ComputeBBox();
3966 }
3967 if (has_runtime)
3969 else if (fgVerboseLevel > 0)
3970 Info("CheckGeometry", "...Nothing to fix");
3971 // Compute bounding box for assemblies
3973 while ((vol = (TGeoVolume *)nextv())) {
3974 if (vol->IsAssembly())
3975 vol->GetShape()->ComputeBBox();
3976 else if (vol->GetMedium() == dummy) {
3977 Warning("CheckGeometry", "Volume \"%s\" has no medium: assigned dummy medium and material", vol->GetName());
3978 vol->SetMedium(dummy);
3979 }
3980 }
3981}
3982
3983////////////////////////////////////////////////////////////////////////////////
3984/// Check all geometry for illegal overlaps within a limit OVLP.
3985
3987{
3988 if (!fTopNode) {
3989 Error("CheckOverlaps", "Top node not set");
3990 return;
3991 }
3993}
3994
3995////////////////////////////////////////////////////////////////////////////////
3996/// Check all geometry for illegal overlaps within a limit OVLP.
3997
3999{
4000 if (!fTopNode) {
4001 Error("CheckOverlaps", "Top node not set");
4002 return;
4003 }
4004 fTopNode->CheckOverlapsBySampling(ovlp, npoints);
4005}
4006
4007////////////////////////////////////////////////////////////////////////////////
4008/// Prints the current list of overlaps.
4009
4011{
4012 if (!fOverlaps)
4013 return;
4014 Int_t novlp = fOverlaps->GetEntriesFast();
4015 if (!novlp)
4016 return;
4017 TGeoManager *geom = (TGeoManager *)this;
4018 geom->GetGeomChecker()->PrintOverlaps();
4019}
4020
4021////////////////////////////////////////////////////////////////////////////////
4022/// Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
4023/// Option can be "v" - verbose (default)
4024
4026{
4027 if (!GetGeomChecker())
4028 return 0.;
4029 TString opt(option);
4030 opt.ToLower();
4031 Double_t weight;
4032 TGeoVolume *volume = fTopVolume;
4033 if (opt.Contains("v")) {
4034 if (opt.Contains("a")) {
4035 if (fgVerboseLevel > 0)
4036 Info("Weight", "Computing analytically weight of %s", volume->GetName());
4037 weight = volume->WeightA();
4038 if (fgVerboseLevel > 0)
4039 Info("Weight", "Computed weight: %f [kg]\n", weight);
4040 return weight;
4041 }
4042 if (fgVerboseLevel > 0) {
4043 Info("Weight", "Estimating weight of %s with %g %% precision", fTopVolume->GetName(), 100. * precision);
4044 printf(" event weight err\n");
4045 printf("========================================\n");
4046 }
4047 }
4048 weight = fChecker->Weight(precision, option);
4049 return weight;
4050}
4051
4052////////////////////////////////////////////////////////////////////////////////
4053/// computes the total size in bytes of the branch starting with node.
4054/// The option can specify if all the branch has to be parsed or only the node
4055
4056ULong_t TGeoManager::SizeOf(const TGeoNode * /*node*/, Option_t * /*option*/)
4057{
4058 return 0;
4059}
4060
4061////////////////////////////////////////////////////////////////////////////////
4062/// Stream an object of class TGeoManager.
4063
4065{
4066 if (R__b.IsReading()) {
4067 R__b.ReadClassBuffer(TGeoManager::Class(), this);
4069 CloseGeometry();
4072 } else {
4074 }
4075}
4076
4077////////////////////////////////////////////////////////////////////////////////
4078/// Execute mouse actions on this manager.
4079
4081{
4082 if (!fPainter)
4083 return;
4084 fPainter->ExecuteManagerEvent(this, event, px, py);
4085}
4086
4087////////////////////////////////////////////////////////////////////////////////
4088/// Export this geometry to a file
4089///
4090/// - Case 1: root file or root/xml file
4091/// if filename end with ".root". The key will be named name
4092/// By default the geometry is saved without the voxelisation info.
4093/// Use option 'v" to save the voxelisation info.
4094/// if filename end with ".xml" a root/xml file is produced.
4095///
4096/// - Case 2: C++ script
4097/// if filename end with ".C"
4098///
4099/// - Case 3: gdml file
4100/// if filename end with ".gdml"
4101/// NOTE that to use this option, the PYTHONPATH must be defined like
4102/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/geom/gdml
4103///
4104
4106{
4107 TString sfile(filename);
4108 if (sfile.Contains(".C")) {
4109 // Save geometry as a C++ script
4110 if (fgVerboseLevel > 0)
4111 Info("Export", "Exporting %s %s as C++ code", GetName(), GetTitle());
4113 return 1;
4114 }
4115 if (sfile.Contains(".gdml")) {
4116 // Save geometry as a gdml file
4117 if (fgVerboseLevel > 0)
4118 Info("Export", "Exporting %s %s as gdml code", GetName(), GetTitle());
4119 // C++ version
4120 TString cmd;
4121 cmd = TString::Format("TGDMLWrite::StartGDMLWriting(gGeoManager,\"%s\",\"%s\")", filename, option);
4122 gROOT->ProcessLineFast(cmd);
4123 return 1;
4124 }
4125 if (sfile.Contains(".root") || sfile.Contains(".xml")) {
4126 // Save geometry as a root file
4127 TFile *f = TFile::Open(filename, "recreate");
4128 if (!f || f->IsZombie()) {
4129 Error("Export", "Cannot open file");
4130 return 0;
4131 }
4132 TString keyname = name;
4133 if (keyname.IsNull())
4134 keyname = GetName();
4135 TString opt = option;
4136 opt.ToLower();
4137 if (opt.Contains("v")) {
4139 if (fgVerboseLevel > 0)
4140 Info("Export", "Exporting %s %s as root file. Optimizations streamed.", GetName(), GetTitle());
4141 } else {
4143 if (fgVerboseLevel > 0)
4144 Info("Export", "Exporting %s %s as root file. Optimizations not streamed.", GetName(), GetTitle());
4145 }
4146
4147 const char *precision_dbl = TBufferText::GetDoubleFormat();
4148 const char *precision_flt = TBufferText::GetFloatFormat();
4149 TString new_format_dbl = TString::Format("%%.%dg", TGeoManager::GetExportPrecision());
4150 if (sfile.Contains(".xml")) {
4151 TBufferText::SetDoubleFormat(new_format_dbl.Data());
4152 TBufferText::SetFloatFormat(new_format_dbl.Data());
4153 }
4154 Int_t nbytes = Write(keyname);
4155 if (sfile.Contains(".xml")) {
4156 TBufferText::SetFloatFormat(precision_dbl);
4157 TBufferText::SetDoubleFormat(precision_flt);
4158 }
4159
4161 delete f;
4162 return nbytes;
4163 }
4164 return 0;
4165}
4166
4167////////////////////////////////////////////////////////////////////////////////
4168/// Lock current geometry so that no other geometry can be imported.
4169
4171{
4172 fgLock = kTRUE;
4173}
4174
4175////////////////////////////////////////////////////////////////////////////////
4176/// Unlock current geometry.
4177
4179{
4180 fgLock = kFALSE;
4181}
4182
4183////////////////////////////////////////////////////////////////////////////////
4184/// Check lock state.
4185
4187{
4188 return fgLock;
4189}
4190
4191////////////////////////////////////////////////////////////////////////////////
4192/// Set verbosity level (static function).
4193/// - 0 - suppress messages related to geom-painter visibility level
4194/// - 1 - default value
4195
4200
4201////////////////////////////////////////////////////////////////////////////////
4202/// Return current verbosity level (static function).
4203
4205{
4206 fgVerboseLevel = vl;
4207}
4208
4209////////////////////////////////////////////////////////////////////////////////
4210/// static function
4211/// Import a geometry from a gdml or ROOT file
4212///
4213/// - Case 1: gdml
4214/// if filename ends with ".gdml" the foreign geometry described with gdml
4215/// is imported executing some python scripts in $ROOTSYS/gdml.
4216/// NOTE that to use this option, the PYTHONPATH must be defined like
4217/// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
4218///
4219/// - Case 2: root file (.root) or root/xml file (.xml)
4220/// Import in memory from filename the geometry with key=name.
4221/// if name="" (default), the first TGeoManager object in the file is returned.
4222///
4223/// Note that this function deletes the current gGeoManager (if one)
4224/// before importing the new object.
4225
4226TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
4227{
4228 if (fgLock) {
4229 ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
4230 return nullptr;
4231 }
4232 if (!filename)
4233 return nullptr;
4234 if (fgVerboseLevel > 0)
4235 ::Info("TGeoManager::Import", "Reading geometry from file: %s", filename);
4236
4237 if (gGeoManager)
4238 delete gGeoManager;
4239 gGeoManager = nullptr;
4240
4241 if (strstr(filename, ".gdml")) {
4242 // import from a gdml file
4243 new TGeoManager("GDMLImport", "Geometry imported from GDML");
4244 TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
4245 TGeoVolume *world = (TGeoVolume *)gROOT->ProcessLineFast(cmd);
4246
4247 if (world == nullptr) {
4248 delete gGeoManager;
4249 gGeoManager = nullptr;
4250 ::Error("TGeoManager::Import", "Cannot read file %s", filename);
4251 } else {
4252 gGeoManager->SetTopVolume(world);
4255 }
4256 } else {
4257 // import from a root file
4259 // in case a web file is specified, use the cacheread option to cache
4260 // this file in the cache directory
4261 TFile *f = nullptr;
4262 if (strstr(filename, "http"))
4263 f = TFile::Open(filename, "CACHEREAD");
4264 else
4266 if (!f || f->IsZombie()) {
4267 ::Error("TGeoManager::Import", "Cannot open file");
4268 return nullptr;
4269 }
4270 if (name && strlen(name) > 0) {
4271 gGeoManager = (TGeoManager *)f->Get(name);
4272 } else {
4273 TIter next(f->GetListOfKeys());
4274 TKey *key;
4275 while ((key = (TKey *)next())) {
4276 if (strcmp(key->GetClassName(), "TGeoManager") != 0)
4277 continue;
4278 gGeoManager = (TGeoManager *)key->ReadObj();
4279 break;
4280 }
4281 }
4282 delete f;
4283 }
4284 if (!gGeoManager)
4285 return nullptr;
4286 if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager))
4287 gROOT->GetListOfGeometries()->Add(gGeoManager);
4288 if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager))
4289 gROOT->GetListOfBrowsables()->Add(gGeoManager);
4291 return gGeoManager;
4292}
4293
4294////////////////////////////////////////////////////////////////////////////////
4295/// Update element flags when geometry is loaded from a file.
4296
4298{
4299 if (!fElementTable)
4300 return;
4301 TIter next(fMaterials);
4302 TGeoMaterial *mat;
4303 TGeoMixture *mix;
4304 TGeoElement *elem, *elem_table;
4305 Int_t i, nelem;
4306 while ((mat = (TGeoMaterial *)next())) {
4307 if (mat->IsMixture()) {
4308 mix = (TGeoMixture *)mat;
4309 nelem = mix->GetNelements();
4310 for (i = 0; i < nelem; i++) {
4311 elem = mix->GetElement(i);
4312 if (!elem)
4313 continue;
4314 elem_table = fElementTable->GetElement(elem->Z());
4315 if (!elem_table)
4316 continue;
4317 if (elem != elem_table) {
4318 elem_table->SetDefined(elem->IsDefined());
4319 elem_table->SetUsed(elem->IsUsed());
4320 } else {
4321 elem_table->SetDefined();
4322 }
4323 }
4324 } else {
4325 elem = mat->GetElement();
4326 if (!elem)
4327 continue;
4328 elem_table = fElementTable->GetElement(elem->Z());
4329 if (!elem_table)
4330 continue;
4331 if (elem != elem_table) {
4332 elem_table->SetDefined(elem->IsDefined());
4333 elem_table->SetUsed(elem->IsUsed());
4334 } else {
4335 elem_table->SetUsed();
4336 }
4337 }
4338 }
4339}
4340
4341////////////////////////////////////////////////////////////////////////////////
4342/// Initialize PNE array for fast access via index and unique-id.
4343
4345{
4346 if (fHashPNE) {
4348 TIter next(fHashPNE);
4349 TObject *obj;
4350 while ((obj = next())) {
4351 fArrayPNE->Add(obj);
4352 }
4353 return kTRUE;
4354 }
4355 return kFALSE;
4356}
4357
4358////////////////////////////////////////////////////////////////////////////////
4359/// Get time cut for drawing tracks.
4360
4362{
4363 tmin = fTmin;
4364 tmax = fTmax;
4365 return fTimeCut;
4366}
4367
4368////////////////////////////////////////////////////////////////////////////////
4369/// Set time cut interval for drawing tracks. If called with no arguments, time
4370/// cut will be disabled.
4371
4373{
4374 fTmin = tmin;
4375 fTmax = tmax;
4376 if (tmin == 0 && tmax == 999)
4377 fTimeCut = kFALSE;
4378 else
4379 fTimeCut = kTRUE;
4380 if (fTracks && !IsAnimatingTracks())
4381 ModifiedPad();
4382}
4383
4384////////////////////////////////////////////////////////////////////////////////
4385/// Convert coordinates from master volume frame to top.
4386
4387void TGeoManager::MasterToTop(const Double_t *master, Double_t *top) const
4388{
4389 GetCurrentNavigator()->MasterToLocal(master, top);
4390}
4391
4392////////////////////////////////////////////////////////////////////////////////
4393/// Convert coordinates from top volume frame to master.
4394
4395void TGeoManager::TopToMaster(const Double_t *top, Double_t *master) const
4396{
4397 GetCurrentNavigator()->LocalToMaster(top, master);
4398}
4399
4400////////////////////////////////////////////////////////////////////////////////
4401/// Create a parallel world for prioritised navigation. This can be populated
4402/// with physical nodes and can be navigated independently using its API.
4403/// In case the flag SetUseParallelWorldNav is set, any navigation query in the
4404/// main geometry is checked against the parallel geometry, which gets priority
4405/// in case of overlaps with the main geometry volumes.
4406
4412
4413////////////////////////////////////////////////////////////////////////////////
4414/// Activate/deactivate usage of parallel world navigation. Can only be done if
4415/// there is a parallel world. Activating navigation will automatically close
4416/// the parallel geometry.
4417
4419{
4420 if (!fParallelWorld) {
4421 Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
4422 return;
4423 }
4424 if (!flag) {
4425 fUsePWNav = flag;
4426 return;
4427 }
4428 if (!fClosed) {
4429 Error("SetUseParallelWorldNav", "The geometry must be closed first");
4430 return;
4431 }
4432 // Closing the parallel world geometry is mandatory
4434 fUsePWNav = kTRUE;
4435}
4436
4438{
4439 Bool_t val = gGeometryLocked;
4440 gGeometryLocked = new_value;
4441 return val;
4442}
4443
4448
4450{
4451 if (fgDefaultUnits == new_value) {
4452 gGeometryLocked = true;
4453 return;
4454 } else if (gGeometryLocked) {
4455 ::Fatal("TGeoManager", "The system of units may only be changed once, \n"
4456 "BEFORE any elements and materials are created! \n"
4457 "Alternatively unlock the default units at own risk.");
4458 } else if (new_value == kG4Units) {
4459 ::Info("TGeoManager", "Changing system of units to Geant4 units (mm, ns, MeV).");
4460 } else if (new_value == kRootUnits) {
4461 ::Info("TGeoManager", "Changing system of units to ROOT units (cm, s, GeV).");
4462 }
4463 fgDefaultUnits = new_value;
4464}
4465
4470
#define SafeDelete(p)
Definition RConfig.hxx:507
#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
cudaEvent_t event
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:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
unsigned long long ULong64_t
Portable unsigned long integer 8 bytes.
Definition RtypesCore.h:85
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
#define BIT(n)
Definition Rtypes.h:90
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:142
@ 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:417
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define gPad
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
void RecursiveRemove(TObject *obj) override
Recursively remove obj from browser.
Definition TBrowser.cxx:427
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
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
@ 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:6082
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:98
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:3802
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
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 ...
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 * 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.
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
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.
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.
Int_t AddShape(TGeoShape *shape)
Add a shape to the list. Returns index of the shape in list.
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.
static TGeoBuilder * Instance(TGeoManager *geom)
Return pointer to singleton.
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.
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 * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=nullptr)
Make an TGeoArb8 volume.
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.
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.
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.
Int_t AddTransformation(TGeoMatrix *matrix)
Add a matrix to the list. Returns index of the matrix in list.
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.
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.
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.
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 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>'.
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 * 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.
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.
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
Make an assembly of volumes.
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.
Int_t AddMaterial(TGeoMaterial *material)
Add a material to the list. Returns index of the material in list.
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
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.
TGeoVolume * Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar=0)
Create a volume in GEANT3 style.
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,...
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 RegisterMatrix(TGeoMatrix *matrix)
Register a matrix to the list of matrices.
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.
Strategy object for assigning colors and transparency to geometry volumes.
virtual Int_t Transparency(const TGeoVolume *vol) const
Compute the transparency for a given volume.
virtual Int_t Color(const TGeoVolume *vol) const
Compute the color for a given volume.
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
Bool_t IsDefined() const
Definition TGeoElement.h:76
void SetDefined(Bool_t flag=kTRUE)
Definition TGeoElement.h:80
Int_t Z() const
Definition TGeoElement.h:63
void SetUsed(Bool_t flag=kTRUE)
Definition TGeoElement.h:81
Bool_t IsUsed() const
Definition TGeoElement.h:78
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
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)
Enable multi-threaded navigation for at most nthreads worker threads.
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.
static std::mutex & fgMutex
! mutex for navigator booking in MT mode
Definition TGeoManager.h:54
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.
virtual Bool_t IsMixture() const
virtual Int_t GetByteCount() const
TGeoElement * GetElement() const
Get a pointer to the element this material is made of.
virtual Bool_t IsEq(const TGeoMaterial *other) const
return true if the other material has the same physical properties
Geometrical transformation package.
Definition TGeoMatrix.h:39
@ kGeoSavePrimitive
Definition TGeoMatrix.h:49
virtual void ReflectZ(Bool_t leftside, Bool_t rotonly=kFALSE)
Multiply by a reflection respect to XY.
Bool_t IsReflection() const
Definition TGeoMatrix.h:67
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
virtual Int_t GetByteCount() const
Get total size in bytes of this.
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition TGeoMedium.h:23
Int_t GetId() const
Definition TGeoMedium.h:45
@ kMedSavePrimitive
Definition TGeoMedium.h:25
virtual Int_t GetByteCount() const
Definition TGeoMedium.h:44
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.
TGeoNodeCache * GetCache() const
void ResetAll()
Reset the navigator.
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.
void BuildIdArray()
Builds node id array.
void BuildInfoBranch()
Builds info branch. Navigation is possible only after this step.
A node containing local transformation.
Definition TGeoNode.h:155
void SetMatrix(const TGeoMatrix *matrix)
Matrix setter.
Definition TGeoNode.cxx:951
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...
void SetPhysicalNode(TGeoPhysicalNode *node)
Setter for the corresponding physical node.
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 ...
void Refresh()
Refresh this physical node.
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:319
static TGeoVolumeAssembly * MakeAssemblyFromVolume(TGeoVolume *vol)
Make a clone of volume VOL but which is an assembly.
Volume families.
Definition TGeoVolume.h:269
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:45
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:248
void SetLineWidth(Width_t lwidth) override
Set the line width.
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:178
Int_t GetRefCount() const
Definition TGeoVolume.h:134
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:112
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:113
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:247
Int_t GetNdaughters() const
Definition TGeoVolume.h:371
void Grab()
Definition TGeoVolume.h:139
static TClass * Class()
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:386
void Release()
Definition TGeoVolume.h:140
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:245
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:187
TGeoShape * GetShape() const
Definition TGeoVolume.h:193
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:234
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:158
Finder class handling voxels.
void SetNeedRebuild(Bool_t flag=kTRUE)
virtual void Voxelize(Option_t *option="")
Voxelize attached volume according to option If the volume is an assembly, make sure the bbox is comp...
Bool_t NeedRebuild() const
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
Definition TGeoXtru.h:25
Int_t GetNvert() const
Definition TGeoXtru.h:119
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:812
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:461
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:1082
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:424
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition TObject.cxx:987
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1124
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:897
virtual TClass * IsA() const
Definition TObject.h:248
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
void ResetBit(UInt_t f)
Definition TObject.h:203
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1070
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:137
Ssiz_t Length() const
Definition TString.h:426
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition TString.cxx:1171
const char * Data() const
Definition TString.h:385
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:714
Bool_t IsNull() const
Definition TString.h:423
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:2460
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
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 void PrintOverlaps() const =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 SetClippingShape(TGeoShape *shape)=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.
Int_t GetId() const
TVirtualGeoTrack * GetMother() const
virtual TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Recursively search through this track for a daughter particle (at any depth) with the specified id.
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:579
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