Logo ROOT   6.12/07
Reference Guide
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 
15 The manager class for any TGeo geometry. Provides user
16 interface for geometry creation, navigation, state querying,
17 visualization, IO, geometry checking and other utilities.
18 
19 ## General architecture
20 
21  The ROOT geometry package is a tool designed for building, browsing,
22 tracking and visualizing a detector geometry. The code is independent from
23 other external MC for simulation, therefore it does not contain any
24 constraints related to physics. However, the package defines a number of
25 hooks for tracking, such as media, materials, magnetic field or track state flags,
26 in order to allow interfacing to tracking MC's. The final goal is to be
27 able to use the same geometry for several purposes, such as tracking,
28 reconstruction or visualization, taking advantage of the ROOT features
29 related to bookkeeping, I/O, histogramming, browsing and GUI's.
30 
31  The geometrical modeler is the most important component of the package and
32 it provides answers to the basic questions like "Where am I ?" or "How far
33 from the next boundary ?", but also to more complex ones like "How far from
34 the 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
37 containment scheme and a normal CSG binary tree at the level of shapes. An
38 important common feature of all detector geometry descriptions is the
39 mother-daughter concept. This is the most natural approach when tracking
40 is concerned and imposes a set of constraints to the way geometry is defined.
41 Constructive solid geometry composition is used only in order to create more
42 complex shapes from an existing set of primitives through boolean operations.
43 This feature is not implemented yet but in future full definition of boolean
44 expressions will be supported.
45 
46  Practically every geometry defined in GEANT style can be mapped by the modeler.
47 The basic components used for building the logical hierarchy of the geometry
48 are called "volumes" and "nodes". Volumes (sometimes called "solids") are fully
49 defined geometrical objects having a given shape and medium and possibly
50 containing a list of nodes. Nodes represent just positioned instances of volumes
51 inside a container volume and they are not directly defined by user. They are
52 automatically created as a result of adding one volume inside other or dividing
53 a volume. The geometrical transformation hold by nodes is always defined with
54 respect to their mother (relative positioning). Reflection matrices are allowed.
55 All volumes have to be fully aware of their containees when the geometry is
56 closed. They will build additional structures (voxels) in order to fasten-up
57 the search algorithms. Finally, nodes can be regarded as bidirectional links
58 between containers and containees objects.
59 
60  The structure defined in this way is a graph structure since volumes are
61 replicable (same volume can become daughter node of several other volumes),
62 every volume becoming a branch in this graph. Any volume in the logical graph
63 can become the actual top volume at run time (see TGeoManager::SetTopVolume()).
64 All functionalities of the modeler will behave in this case as if only the
65 corresponding 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
70 can be divided according default or user-defined patterns, creating automatically
71 the list of division nodes inside. The elementary volumes created during the
72 dividing process follow the same scheme as usual volumes, therefore it is possible
73 to 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
77 shapes (see class TGeoShape), arbitrary wedges with eight vertices on two parallel
78 planes. All basic primitives inherits from class TGeoBBox since the bounding box
79 of a solid is essential for the tracking algorithms. They also implement the
80 virtual methods defined in the virtual class TGeoShape (point and segment
81 classification). User-defined primitives can be directly plugged into the modeler
82 provided that they override these methods. Composite shapes will be soon supported
83 by the modeler. In order to build a TGeoCompositeShape, one will have to define
84 first the primitive components. The object that handle boolean
85 operations among components is called TGeoBoolCombinator and it has to be
86 constructed providing a string boolean expression between the components names.
87 
88 
89 ## Example for building a simple geometry
90 
91 Begin_Macro(source)
92 ../../../tutorials/geom/rootgeom.C
93 End_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
98 a geometry. It defines a global pointer (gGeoManager) in order to be fully
99 accessible from external code. The mechanism of handling multiple geometries
100 at the same time will be soon implemented.
101 
102  TGeoManager is the owner of all geometry objects defined in a session,
103 therefore users must not try to control their deletion. It contains lists of
104 media, materials, transformations, shapes and volumes. Logical nodes (positioned
105 volumes) are created and destroyed by the TGeoVolume class. Physical
106 nodes and their global transformations are subjected to a caching mechanism
107 due to the sometimes very large memory requirements of logical graph expansion.
108 The caching mechanism is triggered by the total number of physical instances
109 of volumes and the cache manager is a client of TGeoManager. The manager class
110 also controls the painter client. This is linked with ROOT graphical libraries
111 loaded 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
116 that have to be followed in order to be validated by the modeler. There are
117 general rules : volumes needs media and shapes in order to be created,
118 both container and containee volumes must be created before linking them together,
119 and the relative transformation matrix must be provided. All branches must
120 have an upper link point otherwise they will not be considered as part of the
121 geometry. Visibility or tracking properties of volumes can be provided both
122 at build time or after geometry is closed, but global visualization settings
123 (see TGeoPainter class) should not be provided at build time, otherwise the
124 drawing package will be loaded. There is also a list of specific rules :
125 positioned daughters should not extrude their mother or intersect with sisters
126 unless this is specified (see TGeoVolume::AddNodeOverlap()), the top volume
127 (containing all geometry tree) must be specified before closing the geometry
128 and must not be positioned - it represents the global reference frame. After
129 building the full geometry tree, the geometry must be closed
130 (see TGeoManager::CloseGeometry()). Voxelization can be redone per volume after
131 this 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
141 previous example $ROOTSYS/tutorials/geom/rootgeom.C ), the manager class will register
142 itself to ROOT and the logical/physical structures will become immediately browsable.
143 The ROOT browser will display starting from the geometry folder : the list of
144 transformations and media, the top volume and the top logical node. These last
145 two can be fully expanded, any intermediate volume/node in the browser being subject
146 of direct access context menu operations (right mouse button click). All user
147 utilities of classes TGeoManager, TGeoVolume and TGeoNode can be called via the
148 context 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.
155 This can be directly accessed from the context menu of the volume object
156 directly from the browser.
157  There are several drawing options that can be set with
158 TGeoManager::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
185 coordinates :
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 
196 Volumes themselves support different visualization settings :
197  - TGeoVolume::SetVisibility() : set volume visibility.
198  - TGeoVolume::VisibleDaughters() : set daughters visibility.
199 All 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
204 generally apply only to the visible parts of the drawn geometry in order to
205 ease geometry checking, and their implementation is in the TGeoChecker class
206 from 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).
210 This method is drawing the daughters of the volume containing the point one
211 level down, printing the path to the deepest physical node holding this point.
212 It also computes the closest distance to any boundary. The point will be drawn
213 in red.
214 
215 \image html geom_checkpoint.jpg
216 
217 #### Shooting random points.
218  Can be called from TGeoVolume::RandomPoints() (context menu function) and
219 it will draw this volume with current visualization settings. Random points
220 are generated in the bounding box of the top drawn volume. The points are
221 classified and drawn with the color of their deepest container. Only points
222 in visible nodes will be drawn.
223 
224 \image html geom_random1.jpg
225 
226 
227 #### Raytracing.
228  Can be called from TGeoVolume::RandomRays() (context menu of volumes) and
229 will shoot rays from a given point in the local reference frame with random
230 directions. The intersections with displayed nodes will appear as segments
231 having the color of the touched node. Drawn geometry will be then made invisible
232 in order to enhance rays.
233 
234 \image html geom_random2.jpg
235 */
236 
237 #include <stdlib.h>
238 
239 #include "Riostream.h"
240 
241 #include "TROOT.h"
242 #include "TGeoManager.h"
243 #include "TSystem.h"
244 #include "TStyle.h"
245 #include "TVirtualPad.h"
246 #include "TBrowser.h"
247 #include "TFile.h"
248 #include "TKey.h"
249 #include "THashList.h"
250 #include "TClass.h"
251 #include "ThreadLocalStorage.h"
252 
253 #include "TGeoVoxelFinder.h"
254 #include "TGeoElement.h"
255 #include "TGeoMaterial.h"
256 #include "TGeoMedium.h"
257 #include "TGeoMatrix.h"
258 #include "TGeoNode.h"
259 #include "TGeoPhysicalNode.h"
260 #include "TGeoManager.h"
261 #include "TGeoPara.h"
262 #include "TGeoParaboloid.h"
263 #include "TGeoTube.h"
264 #include "TGeoEltu.h"
265 #include "TGeoHype.h"
266 #include "TGeoCone.h"
267 #include "TGeoSphere.h"
268 #include "TGeoArb8.h"
269 #include "TGeoPgon.h"
270 #include "TGeoTrd1.h"
271 #include "TGeoTrd2.h"
272 #include "TGeoTorus.h"
273 #include "TGeoXtru.h"
274 #include "TGeoCompositeShape.h"
275 #include "TGeoBoolNode.h"
276 #include "TGeoBuilder.h"
277 #include "TVirtualGeoPainter.h"
278 #include "TPluginManager.h"
279 #include "TVirtualGeoTrack.h"
280 #include "TQObject.h"
281 #include "TMath.h"
282 #include "TEnv.h"
283 #include "TGeoParallelWorld.h"
284 #include "TGeoRegion.h"
285 
286 // statics and globals
287 
291 
292 std::mutex TGeoManager::fgMutex;
301 
302 ////////////////////////////////////////////////////////////////////////////////
303 /// Default constructor.
304 
306 {
309  fTimeCut = kFALSE;
310  fTmin = 0.;
311  fTmax = 999.;
312  fPhiCut = kFALSE;
313  fPhimin = 0;
314  fPhimax = 360;
315  fDrawExtra = kFALSE;
319  fClosed = kFALSE;
321  fBits = 0;
322  fCurrentNavigator = 0;
323  fMaterials = 0;
324  fHashPNE = 0;
325  fArrayPNE = 0;
326  fMatrices = 0;
327  fNodes = 0;
328  fOverlaps = 0;
329  fRegions = 0;
330  fNNodes = 0;
331  fMaxVisNodes = 10000;
332  fVolumes = 0;
333  fPhysicalNodes = 0;
334  fShapes = 0;
335  fGVolumes = 0;
336  fGShapes = 0;
337  fTracks = 0;
338  fMedia = 0;
339  fNtracks = 0;
340  fNpdg = 0;
341  fPdgNames = 0;
342  memset(fPdgId, 0, 1024*sizeof(Int_t));
343  fCurrentTrack = 0;
344  fCurrentVolume = 0;
345  fTopVolume = 0;
346  fTopNode = 0;
347  fMasterVolume = 0;
348  fPainter = 0;
349  fActivity = kFALSE;
351  fVisDensity = 0.;
352  fVisLevel = 3;
353  fVisOption = 1;
354  fExplodedView = 0;
355  fNsegments = 20;
356  fNLevel = 0;
357  fUniqueVolumes = 0;
358  fNodeIdArray = 0;
359  fClippingShape = 0;
362  fGLMatrix = 0;
363  fPaintVolume = 0;
364  fUserPaintVolume = 0;
365  fElementTable = 0;
366  fHashVolumes = 0;
367  fHashGVolumes = 0;
368  fSizePNEId = 0;
369  fNPNEId = 0;
370  fKeyPNEId = 0;
371  fValuePNEId = 0;
373  fRaytraceMode = 0;
374  fMaxThreads = 0;
375  fUsePWNav = kFALSE;
376  fParallelWorld = 0;
377  ClearThreadsMap();
378  } else {
379  Init();
382  }
383 }
384 
385 ////////////////////////////////////////////////////////////////////////////////
386 /// Constructor.
387 
388 TGeoManager::TGeoManager(const char *name, const char *title)
389  :TNamed(name, title)
390 {
391  if (!gROOT->GetListOfGeometries()->FindObject(this)) gROOT->GetListOfGeometries()->Add(this);
392  if (!gROOT->GetListOfBrowsables()->FindObject(this)) gROOT->GetListOfBrowsables()->Add(this);
393  Init();
394  gGeoIdentity = new TGeoIdentity("Identity");
396  if (fgVerboseLevel>0) Info("TGeoManager","Geometry %s, %s created", GetName(), GetTitle());
397 }
398 
399 ////////////////////////////////////////////////////////////////////////////////
400 /// Initialize manager class.
401 
402 void TGeoManager::Init()
403 {
404  if (gGeoManager) {
405  Warning("Init","Deleting previous geometry: %s/%s",gGeoManager->GetName(),gGeoManager->GetTitle());
406  delete gGeoManager;
407  if (fgLock) Fatal("Init", "New geometry created while the old one locked !!!");
408  }
409 
410  gGeoManager = this;
412  fTimeCut = kFALSE;
413  fTmin = 0.;
414  fTmax = 999.;
415  fPhiCut = kFALSE;
416  fPhimin = 0;
417  fPhimax = 360;
418  fDrawExtra = kFALSE;
422  fClosed = kFALSE;
424  fBits = new UChar_t[50000]; // max 25000 nodes per volume
425  fCurrentNavigator = 0;
426  fHashPNE = new THashList(256,3);
427  fArrayPNE = 0;
428  fMaterials = new THashList(200,3);
429  fMatrices = new TObjArray(256);
430  fNodes = new TObjArray(30);
431  fOverlaps = new TObjArray(256);
432  fRegions = new TObjArray(256);
433  fNNodes = 0;
434  fMaxVisNodes = 10000;
435  fVolumes = new TObjArray(256);
436  fPhysicalNodes = new TObjArray(256);
437  fShapes = new TObjArray(256);
438  fGVolumes = new TObjArray(256);
439  fGShapes = new TObjArray(256);
440  fTracks = new TObjArray(256);
441  fMedia = new THashList(200,3);
442  fNtracks = 0;
443  fNpdg = 0;
444  fPdgNames = 0;
445  memset(fPdgId, 0, 1024*sizeof(Int_t));
446  fCurrentTrack = 0;
447  fCurrentVolume = 0;
448  fTopVolume = 0;
449  fTopNode = 0;
450  fMasterVolume = 0;
451  fPainter = 0;
452  fActivity = kFALSE;
454  fVisDensity = 0.;
455  fVisLevel = 3;
456  fVisOption = 1;
457  fExplodedView = 0;
458  fNsegments = 20;
459  fNLevel = 0;
460  fUniqueVolumes = new TObjArray(256);
461  fNodeIdArray = 0;
462  fClippingShape = 0;
465  fGLMatrix = new TGeoHMatrix();
466  fPaintVolume = 0;
467  fUserPaintVolume = 0;
468  fElementTable = 0;
469  fHashVolumes = 0;
470  fHashGVolumes = 0;
471  fSizePNEId = 0;
472  fNPNEId = 0;
473  fKeyPNEId = 0;
474  fValuePNEId = 0;
476  fRaytraceMode = 0;
477  fMaxThreads = 0;
478  fUsePWNav = kFALSE;
479  fParallelWorld = 0;
480  ClearThreadsMap();
481 }
482 
483 ////////////////////////////////////////////////////////////////////////////////
484 ///copy constructor
485 
487  TNamed(gm),
488  fPhimin(gm.fPhimin),
489  fPhimax(gm.fPhimax),
490  fTmin(gm.fTmin),
491  fTmax(gm.fTmax),
492  fNNodes(gm.fNNodes),
497  fVisLevel(gm.fVisLevel),
499  fNtracks(gm.fNtracks),
502  fNpdg(gm.fNpdg),
503  fClosed(gm.fClosed),
508  fPhiCut(gm.fPhiCut),
509  fTimeCut(gm.fTimeCut),
513  fActivity(gm.fActivity),
515  fPainter(gm.fPainter),
516  fMatrices(gm.fMatrices),
517  fShapes(gm.fShapes),
518  fVolumes(gm.fVolumes),
520  fGShapes(gm.fGShapes),
521  fGVolumes(gm.fGVolumes),
522  fTracks(gm.fTracks),
523  fPdgNames(gm.fPdgNames),
525  fMedia(gm.fMedia),
526  fNodes(gm.fNodes),
527  fOverlaps(gm.fOverlaps),
528  fRegions(gm.fRegions),
529  fBits(gm.fBits),
533  fTopNode(gm.fTopNode),
535  fGLMatrix(gm.fGLMatrix),
540  fNLevel(gm.fNLevel),
545  fHashPNE(gm.fHashPNE),
546  fArrayPNE(gm.fArrayPNE),
547  fSizePNEId(0),
548  fNPNEId(0),
549  fKeyPNEId(0),
550  fValuePNEId(0),
551  fMaxThreads(0),
553  fRaytraceMode(0),
554  fUsePWNav(kFALSE),
555  fParallelWorld(0)
556 {
557  for(Int_t i=0; i<1024; i++)
558  fPdgId[i]=gm.fPdgId[i];
560  ClearThreadsMap();
561 }
562 
563 ////////////////////////////////////////////////////////////////////////////////
564 ///assignment operator
565 
567 {
569  if(this!=&gm) {
570  TNamed::operator=(gm);
571  fPhimin=gm.fPhimin;
572  fPhimax=gm.fPhimax;
573  fTmin=gm.fTmin;
574  fTmax=gm.fTmax;
575  fNNodes=gm.fNNodes;
580  fVisLevel=gm.fVisLevel;
582  fNtracks=gm.fNtracks;
585  fNpdg=gm.fNpdg;
586  for(Int_t i=0; i<1024; i++)
587  fPdgId[i]=gm.fPdgId[i];
588  fClosed=gm.fClosed;
593  fPhiCut=gm.fPhiCut;
594  fTimeCut=gm.fTimeCut;
598  fActivity=gm.fActivity;
600  fPainter=gm.fPainter;
601  fMatrices=gm.fMatrices;
602  fShapes=gm.fShapes;
603  fVolumes=gm.fVolumes;
605  fGShapes=gm.fGShapes;
606  fGVolumes=gm.fGVolumes;
607  fTracks=gm.fTracks;
608  fPdgNames=gm.fPdgNames;
610  fMedia=gm.fMedia;
611  fNodes=gm.fNodes;
612  fOverlaps=gm.fOverlaps;
613  fRegions=gm.fRegions;
614  fBits=gm.fBits;
618  fTopNode=gm.fTopNode;
620  fGLMatrix=gm.fGLMatrix;
625  fNLevel=gm.fNLevel;
630  fHashPNE=gm.fHashPNE;
631  fArrayPNE=gm.fArrayPNE;
632  fSizePNEId = 0;
633  fNPNEId = 0;
634  fKeyPNEId = 0;
635  fValuePNEId = 0;
637  fRaytraceMode = 0;
638  fMaxThreads = 0;
639  fUsePWNav = kFALSE;
640  fParallelWorld = 0;
641  ClearThreadsMap();
642  ClearThreadData();
643  }
644  return *this;
645 }
646 
647 ////////////////////////////////////////////////////////////////////////////////
648 /// Destructor
649 
651 {
652  if (gGeoManager != this) gGeoManager = this;
654 
655  if (gROOT->GetListOfFiles()) { //in case this function is called from TROOT destructor
656  gROOT->GetListOfGeometries()->Remove(this);
657  gROOT->GetListOfBrowsables()->Remove(this);
658  }
659 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
660 // TIter next(brlist);
661 // TBrowser *browser = 0;
662 // while ((browser=(TBrowser*)next())) browser->RecursiveRemove(this);
663  ClearThreadsMap();
664  ClearThreadData();
665  delete TGeoBuilder::Instance(this);
666  if (fBits) delete [] fBits;
673  if (fMedia) {fMedia->Delete(); SafeDelete(fMedia);}
677  if (fArrayPNE) {delete fArrayPNE;}
679  if (fShapes) {fShapes->Delete(); SafeDelete( fShapes );}
682  if (fTracks) {fTracks->Delete(); SafeDelete( fTracks );}
685  ClearNavigators();
686  CleanGarbage();
687  SafeDelete( fPainter );
689  if (fSizePNEId) {
690  delete [] fKeyPNEId;
691  delete [] fValuePNEId;
692  }
693  delete fParallelWorld;
695  gGeoIdentity = 0;
696  gGeoManager = 0;
697 }
698 
699 ////////////////////////////////////////////////////////////////////////////////
700 /// Add a material to the list. Returns index of the material in list.
701 
703 {
704  return TGeoBuilder::Instance(this)->AddMaterial((TGeoMaterial*)material);
705 }
706 
707 ////////////////////////////////////////////////////////////////////////////////
708 /// Add an illegal overlap/extrusion to the list.
709 
711 {
712  Int_t size = fOverlaps->GetEntriesFast();
713  fOverlaps->Add((TObject*)ovlp);
714  return size;
715 }
716 
717 ////////////////////////////////////////////////////////////////////////////////
718 /// Add a new region of volumes.
720 {
721  Int_t size = fRegions->GetEntriesFast();
722  fRegions->Add(region);
723  return size;
724 }
725 
726 ////////////////////////////////////////////////////////////////////////////////
727 /// Add a matrix to the list. Returns index of the matrix in list.
728 
730 {
731  return TGeoBuilder::Instance(this)->AddTransformation((TGeoMatrix*)matrix);
732 }
733 
734 ////////////////////////////////////////////////////////////////////////////////
735 /// Add a shape to the list. Returns index of the shape in list.
736 
738 {
739  return TGeoBuilder::Instance(this)->AddShape((TGeoShape*)shape);
740 }
741 
742 ////////////////////////////////////////////////////////////////////////////////
743 /// Add a track to the list of tracks. Use this for primaries only. For secondaries,
744 /// add them to the parent track. The method create objects that are registered
745 /// to the analysis manager but have to be cleaned-up by the user via ClearTracks().
746 
747 Int_t TGeoManager::AddTrack(Int_t id, Int_t pdgcode, TObject *particle)
748 {
749  Int_t index = fNtracks;
750  fTracks->AddAtAndExpand(GetGeomPainter()->AddTrack(id,pdgcode,particle),fNtracks++);
751  return index;
752 }
753 
754 ////////////////////////////////////////////////////////////////////////////////
755 /// Add a track to the list of tracks
756 
758 {
759  Int_t index = fNtracks;
760  fTracks->AddAtAndExpand(track,fNtracks++);
761  return index;
762 }
763 
764 ////////////////////////////////////////////////////////////////////////////////
765 /// Makes a primary track but do not attach it to the list of tracks. The track
766 /// can be attached as daughter to another one with TVirtualGeoTrack::AddTrack
767 
769 {
770  TVirtualGeoTrack *track = GetGeomPainter()->AddTrack(id,pdgcode,particle);
771  return track;
772 }
773 
774 ////////////////////////////////////////////////////////////////////////////////
775 /// Add a volume to the list. Returns index of the volume in list.
776 
778 {
779  if (!volume) {
780  Error("AddVolume", "invalid volume");
781  return -1;
782  }
784  if (!uid) 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);
804  fHashGVolumes = new THashList(256);
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) { TGeoManager::ThreadId(); fgMutex.lock(); }
825  std::thread::id threadId = std::this_thread::get_id();
826  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
827  TGeoNavigatorArray *array = 0;
828  if (it != fNavigators.end()) array = it->second;
829  else {
830  array = new TGeoNavigatorArray(this);
831  fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
832  }
833  TGeoNavigator *nav = array->AddNavigator();
834  if (fClosed) nav->GetCache()->BuildInfoBranch();
835  if (fMultiThread) fgMutex.unlock();
836  return nav;
837 }
838 
839 ////////////////////////////////////////////////////////////////////////////////
840 /// Returns current navigator for the calling thread.
841 
843 {
844  TTHREAD_TLS(TGeoNavigator*) tnav = 0;
845  if (!fMultiThread) return fCurrentNavigator;
846  TGeoNavigator *nav = tnav; // TTHREAD_TLS_GET(TGeoNavigator*,tnav);
847  if (nav) return nav;
848  std::thread::id threadId = std::this_thread::get_id();
849  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
850  if (it == fNavigators.end()) return 0;
851  TGeoNavigatorArray *array = it->second;
852  nav = array->GetCurrentNavigator();
853  tnav = nav; // TTHREAD_TLS_SET(TGeoNavigator*,tnav,nav);
854  return nav;
855 }
856 
857 ////////////////////////////////////////////////////////////////////////////////
858 /// Get list of navigators for the calling thread.
859 
861 {
862  std::thread::id threadId = std::this_thread::get_id();
863  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
864  if (it == fNavigators.end()) return 0;
865  TGeoNavigatorArray *array = it->second;
866  return array;
867 }
868 
869 ////////////////////////////////////////////////////////////////////////////////
870 /// Switch to another existing navigator for the calling thread.
871 
873 {
874  std::thread::id threadId = std::this_thread::get_id();
875  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
876  if (it == fNavigators.end()) {
877  Error("SetCurrentNavigator", "No navigator defined for this thread\n");
878  std::cout << " thread id: " << threadId << std::endl;
879  return kFALSE;
880  }
881  TGeoNavigatorArray *array = it->second;
882  TGeoNavigator *nav = array->SetCurrentNavigator(index);
883  if (!nav) {
884  Error("SetCurrentNavigator", "Navigator %d not existing for this thread\n", index);
885  std::cout << " thread id: " << threadId << std::endl;
886  return kFALSE;
887  }
888  if (!fMultiThread) fCurrentNavigator = nav;
889  return kTRUE;
890 }
891 
892 ////////////////////////////////////////////////////////////////////////////////
893 /// Set the lock for navigators.
894 
896 {
897  fgLockNavigators = flag;
898 }
899 
900 ////////////////////////////////////////////////////////////////////////////////
901 /// Clear all navigators.
902 
904 {
905  if (fMultiThread) fgMutex.lock();
906  TGeoNavigatorArray *arr = 0;
907  for (NavigatorsMap_t::iterator it = fNavigators.begin();
908  it != fNavigators.end(); ++it) {
909  arr = (*it).second;
910  if (arr) delete arr;
911  }
912  fNavigators.clear();
913  if (fMultiThread) fgMutex.unlock();
914 }
915 
916 ////////////////////////////////////////////////////////////////////////////////
917 /// Clear a single navigator.
918 
920 {
921  if (fMultiThread) fgMutex.lock();
922  for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
923  TGeoNavigatorArray *arr = (*it).second;
924  if (arr) {
925  if ((TGeoNavigator*)arr->Remove((TObject*)nav)) {
926  delete nav;
927  if (!arr->GetEntries()) fNavigators.erase(it);
928  if (fMultiThread) fgMutex.unlock();
929  return;
930  }
931  }
932  }
933  Error("Remove navigator", "Navigator %p not found", nav);
934  if (fMultiThread) fgMutex.unlock();
935 }
936 
937 ////////////////////////////////////////////////////////////////////////////////
938 /// Set maximum number of threads for navigation.
939 
940 void TGeoManager::SetMaxThreads(Int_t nthreads)
941 {
942  if (!fClosed) {
943  Error("SetMaxThreads", "Cannot set maximum number of threads before closing the geometry");
944  return;
945  }
946  if (!fMultiThread) {
948  std::thread::id threadId = std::this_thread::get_id();
949  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
950  if (it != fNavigators.end()) {
951  TGeoNavigatorArray *array = it->second;
952  fNavigators.erase(it);
953  fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
954  }
955  }
956  if (fMaxThreads) {
957  ClearThreadsMap();
958  ClearThreadData();
959  }
960  fMaxThreads = nthreads+1;
961  if (fMaxThreads>0) {
964  }
965 }
966 
967 ////////////////////////////////////////////////////////////////////////////////
968 
969 void TGeoManager::ClearThreadData() const
970 {
971  if (!fMaxThreads) return;
972  fgMutex.lock();
973  TIter next(fVolumes);
974  TGeoVolume *vol;
975  while ((vol=(TGeoVolume*)next())) vol->ClearThreadData();
976  fgMutex.unlock();
977 }
978 
979 ////////////////////////////////////////////////////////////////////////////////
980 /// Create thread private data for all geometry objects.
981 
983 {
984  if (!fMaxThreads) return;
985  fgMutex.lock();
986  TIter next(fVolumes);
987  TGeoVolume *vol;
988  while ((vol=(TGeoVolume*)next())) vol->CreateThreadData(fMaxThreads);
989  fgMutex.unlock();
990 }
991 
992 ////////////////////////////////////////////////////////////////////////////////
993 /// Clear the current map of threads. This will be filled again by the calling
994 /// threads via ThreadId calls.
995 
997 {
998  if (gGeoManager && !gGeoManager->IsMultiThread()) return;
999  fgMutex.lock();
1000  if (!fgThreadId->empty()) fgThreadId->clear();
1001  fgNumThreads = 0;
1002  fgMutex.unlock();
1003 }
1004 
1005 ////////////////////////////////////////////////////////////////////////////////
1006 /// Translates the current thread id to an ordinal number. This can be used to
1007 /// manage data which is specific for a given thread.
1008 
1011  TTHREAD_TLS(Int_t) tid = -1;
1012  Int_t ttid = tid; // TTHREAD_TLS_GET(Int_t,tid);
1013  if (ttid > -1) return ttid;
1014  if (gGeoManager && !gGeoManager->IsMultiThread()) return 0;
1015  std::thread::id threadId = std::this_thread::get_id();
1016  TGeoManager::ThreadsMapIt_t it = fgThreadId->find(threadId);
1017  if (it != fgThreadId->end()) return it->second;
1018  // Map needs to be updated.
1019  fgMutex.lock();
1020  (*fgThreadId)[threadId] = fgNumThreads;
1021  tid = fgNumThreads; // TTHREAD_TLS_SET(Int_t,tid,fgNumThreads);
1022  ttid = fgNumThreads++;
1023  fgMutex.unlock();
1024  return ttid;
1025 }
1026 
1027 ////////////////////////////////////////////////////////////////////////////////
1028 /// Describe how to browse this object.
1029 
1032  if (!b) return;
1033  if (fMaterials) b->Add(fMaterials, "Materials");
1034  if (fMedia) b->Add(fMedia, "Media");
1035  if (fMatrices) b->Add(fMatrices, "Local transformations");
1036  if (fOverlaps) b->Add(fOverlaps, "Illegal overlaps");
1037  if (fTracks) b->Add(fTracks, "Tracks");
1038  if (fMasterVolume) b->Add(fMasterVolume, "Master Volume", fMasterVolume->IsVisible());
1039  if (fTopVolume) b->Add(fTopVolume, "Top Volume", fTopVolume->IsVisible());
1040  if (fTopNode) b->Add(fTopNode);
1041  TString browserImp(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
1042  TQObject::Connect(browserImp.Data(), "Checked(TObject*,Bool_t)",
1043  "TGeoManager", this, "SetVisibility(TObject*,Bool_t)");
1044 }
1045 
1046 ////////////////////////////////////////////////////////////////////////////////
1047 /// Append a pad for this geometry.
1048 
1049 void TGeoManager::Edit(Option_t *option) {
1051  GetGeomPainter()->EditGeometry(option);
1052 }
1053 
1054 ////////////////////////////////////////////////////////////////////////////////
1055 /// Set visibility for a volume.
1056 
1059  if(obj->IsA() == TGeoVolume::Class()) {
1060  TGeoVolume *vol = (TGeoVolume *) obj;
1061  vol->SetVisibility(vis);
1062  } else {
1063  if (obj->InheritsFrom(TGeoNode::Class())) {
1064  TGeoNode *node = (TGeoNode *) obj;
1065  node->SetVisibility(vis);
1066  } else return;
1067  }
1069 }
1070 
1071 ////////////////////////////////////////////////////////////////////////////////
1072 /// Get the new 'bombed' translation vector according current exploded view mode.
1073 
1074 void TGeoManager::BombTranslation(const Double_t *tr, Double_t *bombtr)
1076  if (fPainter) fPainter->BombTranslation(tr, bombtr);
1077  return;
1078 }
1079 
1080 ////////////////////////////////////////////////////////////////////////////////
1081 /// Get the new 'unbombed' translation vector according current exploded view mode.
1082 
1083 void TGeoManager::UnbombTranslation(const Double_t *tr, Double_t *bombtr)
1085  if (fPainter) fPainter->UnbombTranslation(tr, bombtr);
1086  return;
1087 }
1088 
1089 ////////////////////////////////////////////////////////////////////////////////
1090 /// Backup the current state without affecting the cache stack.
1091 
1095 }
1096 
1097 ////////////////////////////////////////////////////////////////////////////////
1098 /// Restore a backed-up state without affecting the cache stack.
1099 
1103 }
1104 
1105 ////////////////////////////////////////////////////////////////////////////////
1106 /// Register a matrix to the list of matrices. It will be cleaned-up at the
1107 /// destruction TGeoManager.
1108 
1109 void TGeoManager::RegisterMatrix(const TGeoMatrix *matrix)
1111  return TGeoBuilder::Instance(this)->RegisterMatrix((TGeoMatrix*)matrix);
1112 }
1113 
1114 ////////////////////////////////////////////////////////////////////////////////
1115 /// Replaces all occurrences of VORIG with VNEW in the geometry tree. The volume VORIG
1116 /// is not replaced from the list of volumes, but all node referencing it will reference
1117 /// VNEW instead. Returns number of occurrences changed.
1118 
1121  Int_t nref = 0;
1122  if (!vorig || !vnew) return nref;
1123  TGeoMedium *morig = vorig->GetMedium();
1124  Bool_t checkmed = kFALSE;
1125  if (morig) checkmed = kTRUE;
1126  TGeoMedium *mnew = vnew->GetMedium();
1127  // Try to limit the damage produced by incorrect usage.
1128  if (!mnew && !vnew->IsAssembly()) {
1129  Error("ReplaceVolume","Replacement volume %s has no medium and it is not an assembly",
1130  vnew->GetName());
1131  return nref;
1132  }
1133  if (mnew && checkmed) {
1134  if (mnew->GetId() != morig->GetId())
1135  Warning("ReplaceVolume","Replacement volume %s has different medium than original volume %s",
1136  vnew->GetName(), vorig->GetName());
1137  checkmed = kFALSE;
1138  }
1139 
1140  // Medium checking now performed only if replacement is an assembly and old volume a real one.
1141  // Check result is dependent on positioning.
1142  Int_t nvol = fVolumes->GetEntriesFast();
1143  Int_t i,j,nd;
1144  Int_t ierr = 0;
1145  TGeoVolume *vol;
1146  TGeoNode *node;
1147  TGeoVoxelFinder *voxels;
1148  for (i=0; i<nvol; i++) {
1149  vol = (TGeoVolume*)fVolumes->At(i);
1150  if (!vol) continue;
1151  if (vol==vorig || vol==vnew) continue;
1152  nd = vol->GetNdaughters();
1153  for (j=0; j<nd; j++) {
1154  node = vol->GetNode(j);
1155  if (node->GetVolume() == vorig) {
1156  if (checkmed) {
1157  mnew = node->GetMotherVolume()->GetMedium();
1158  if (mnew && mnew->GetId()!=morig->GetId()) ierr++;
1159  }
1160  nref++;
1161  if (node->IsOverlapping()) {
1162  node->SetOverlapping(kFALSE);
1163  Info("ReplaceVolume","%s replaced with assembly and declared NON-OVERLAPPING!",node->GetName());
1164  }
1165  node->SetVolume(vnew);
1166  voxels = node->GetMotherVolume()->GetVoxels();
1167  if (voxels) voxels->SetNeedRebuild();
1168  } else {
1169  if (node->GetMotherVolume() == vorig) {
1170  nref++;
1171  node->SetMotherVolume(vnew);
1172  if (node->IsOverlapping()) {
1173  node->SetOverlapping(kFALSE);
1174  Info("ReplaceVolume","%s inside substitute assembly %s declared NON-OVERLAPPING!",node->GetName(),vnew->GetName());
1175  }
1176  }
1177  }
1178  }
1179  }
1180  if (ierr) Warning("ReplaceVolume", "Volumes should not be replaced with assemblies if they are positioned in containers having a different medium ID.\n %i occurrences for assembly replacing volume %s",
1181  ierr, vorig->GetName());
1182  return nref;
1183 }
1184 
1185 ////////////////////////////////////////////////////////////////////////////////
1186 /// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1187 
1190  TGeoVolume *toTransform = FindVolumeFast(vname);
1191  if (!toTransform) {
1192  Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1193  return 0;
1194  }
1195  Int_t index = fVolumes->IndexOf(toTransform);
1196  Int_t count = 0;
1197  Int_t indmax = fVolumes->GetEntries();
1198  Bool_t replace = kTRUE;
1199  TGeoVolume *transformed;
1200  while (index<indmax) {
1201  if (replace) {
1202  replace = kFALSE;
1203  transformed = TGeoVolumeAssembly::MakeAssemblyFromVolume(toTransform);
1204  if (transformed) {
1205  ReplaceVolume(toTransform, transformed);
1206  count++;
1207  } else {
1208  if (toTransform->IsAssembly())
1209  Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1210  if (!toTransform->GetNdaughters())
1211  Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform", toTransform->GetName());
1212  if (toTransform->IsVolumeMulti())
1213  Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1214  }
1215  }
1216  index++;
1217  if (index >= indmax) return count;
1218  toTransform = (TGeoVolume*)fVolumes->At(index);
1219  if (!strcmp(toTransform->GetName(),vname)) replace = kTRUE;
1220  }
1221  return count;
1222 }
1223 
1224 ////////////////////////////////////////////////////////////////////////////////
1225 /// Create a new volume by dividing an existing one (GEANT3 like)
1226 ///
1227 /// Divides MOTHER into NDIV divisions called NAME
1228 /// along axis IAXIS starting at coordinate value START
1229 /// and having size STEP. The created volumes will have tracking
1230 /// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1231 /// The behavior of the division operation can be triggered using OPTION :
1232 ///
1233 /// OPTION (case insensitive) :
1234 /// - N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1235 /// - NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1236 /// - S - divide all range with given STEP. NDIV is computed and divisions will be centered
1237 /// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1238 /// - SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1239 
1240 TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis,
1241  Int_t ndiv, Double_t start, Double_t step, Int_t numed, Option_t *option)
1242 {
1243  return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1244 }
1245 
1246 ////////////////////////////////////////////////////////////////////////////////
1247 /// Create rotation matrix named 'mat<index>'.
1248 ///
1249 /// - index rotation matrix number
1250 /// - theta1 polar angle for axis X
1251 /// - phi1 azimuthal angle for axis X
1252 /// - theta2 polar angle for axis Y
1253 /// - phi2 azimuthal angle for axis Y
1254 /// - theta3 polar angle for axis Z
1255 /// - phi3 azimuthal angle for axis Z
1256 ///
1257 
1258 void TGeoManager::Matrix(Int_t index, Double_t theta1, Double_t phi1,
1259  Double_t theta2, Double_t phi2,
1260  Double_t theta3, Double_t phi3)
1261 {
1262  TGeoBuilder::Instance(this)->Matrix(index, theta1, phi1, theta2, phi2, theta3, phi3);
1263 }
1264 
1265 ////////////////////////////////////////////////////////////////////////////////
1266 /// Create material with given A, Z and density, having an unique id.
1267 
1268 TGeoMaterial *TGeoManager::Material(const char *name, Double_t a, Double_t z, Double_t dens, Int_t uid,Double_t radlen, Double_t intlen)
1270  return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1271 
1272 }
1273 
1274 ////////////////////////////////////////////////////////////////////////////////
1275 /// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1276 /// materials defined by arrays A,Z and WMAT, having an unique id.
1277 
1279  Int_t nelem, Float_t *wmat, Int_t uid)
1280 {
1281  return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1282 }
1283 
1284 ////////////////////////////////////////////////////////////////////////////////
1285 /// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1286 /// materials defined by arrays A,Z and WMAT, having an unique id.
1287 
1289  Int_t nelem, Double_t *wmat, Int_t uid)
1290 {
1291  return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1292 }
1293 
1294 ////////////////////////////////////////////////////////////////////////////////
1295 /// Create tracking medium
1296 ///
1297 /// - numed tracking medium number assigned
1298 /// - name tracking medium name
1299 /// - nmat material number
1300 /// - isvol sensitive volume flag
1301 /// - ifield magnetic field
1302 /// - fieldm max. field value (kilogauss)
1303 /// - tmaxfd max. angle due to field (deg/step)
1304 /// - stemax max. step allowed
1305 /// - deemax max. fraction of energy lost in a step
1306 /// - epsil tracking precision (cm)
1307 /// - stmin min. step due to continuous processes (cm)
1308 ///
1309 /// - ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1310 /// - ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1311 /// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1312 ///
1313 
1314 TGeoMedium *TGeoManager::Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol,
1315  Int_t ifield, Double_t fieldm, Double_t tmaxfd,
1316  Double_t stemax, Double_t deemax, Double_t epsil,
1317  Double_t stmin)
1318 {
1319  return TGeoBuilder::Instance(this)->Medium(name, numed, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
1320 }
1321 
1322 ////////////////////////////////////////////////////////////////////////////////
1323 /// Create a node called <name_nr> pointing to the volume called <name>
1324 /// as daughter of the volume called <mother> (gspos). The relative matrix is
1325 /// made of : a translation (x,y,z) and a rotation matrix named <matIROT>.
1326 /// In case npar>0, create the volume to be positioned in mother, according
1327 /// its actual parameters (gsposp).
1328 /// - NAME Volume name
1329 /// - NUMBER Copy number of the volume
1330 /// - MOTHER Mother volume name
1331 /// - X X coord. of the volume in mother ref. sys.
1332 /// - Y Y coord. of the volume in mother ref. sys.
1333 /// - Z Z coord. of the volume in mother ref. sys.
1334 /// - IROT Rotation matrix number w.r.t. mother ref. sys.
1335 /// - ISONLY ONLY/MANY flag
1336 
1337 void TGeoManager::Node(const char *name, Int_t nr, const char *mother,
1339  Bool_t isOnly, Float_t *upar, Int_t npar)
1340 {
1341  TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1342 }
1343 
1344 ////////////////////////////////////////////////////////////////////////////////
1345 /// Create a node called <name_nr> pointing to the volume called <name>
1346 /// as daughter of the volume called <mother> (gspos). The relative matrix is
1347 /// made of : a translation (x,y,z) and a rotation matrix named <matIROT>.
1348 /// In case npar>0, create the volume to be positioned in mother, according
1349 /// its actual parameters (gsposp).
1350 /// - NAME Volume name
1351 /// - NUMBER Copy number of the volume
1352 /// - MOTHER Mother volume name
1353 /// - X X coord. of the volume in mother ref. sys.
1354 /// - Y Y coord. of the volume in mother ref. sys.
1355 /// - Z Z coord. of the volume in mother ref. sys.
1356 /// - IROT Rotation matrix number w.r.t. mother ref. sys.
1357 /// - ISONLY ONLY/MANY flag
1358 
1359 void TGeoManager::Node(const char *name, Int_t nr, const char *mother,
1361  Bool_t isOnly, Double_t *upar, Int_t npar)
1362 {
1363  TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1364 
1365 }
1366 
1367 ////////////////////////////////////////////////////////////////////////////////
1368 /// Create a volume in GEANT3 style.
1369 /// - NAME Volume name
1370 /// - SHAPE Volume type
1371 /// - NMED Tracking medium number
1372 /// - NPAR Number of shape parameters
1373 /// - UPAR Vector containing shape parameters
1374 
1375 TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed,
1376  Float_t *upar, Int_t npar)
1377 {
1378  return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1379 }
1380 
1381 ////////////////////////////////////////////////////////////////////////////////
1382 /// Create a volume in GEANT3 style.
1383 /// - NAME Volume name
1384 /// - SHAPE Volume type
1385 /// - NMED Tracking medium number
1386 /// - NPAR Number of shape parameters
1387 /// - UPAR Vector containing shape parameters
1388 
1389 TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed,
1390  Double_t *upar, Int_t npar)
1391 {
1392  return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1393 }
1394 
1395 ////////////////////////////////////////////////////////////////////////////////
1396 /// Assigns uid's for all materials,media and matrices.
1397 
1400  Int_t index = 1;
1401  TIter next(fMaterials);
1402  TGeoMaterial *mater;
1403  while ((mater=(TGeoMaterial*)next())) {
1404  mater->SetUniqueID(index++);
1406  }
1407  index = 1;
1408  TIter next1(fMedia);
1409  TGeoMedium *med;
1410  while ((med=(TGeoMedium*)next1())) {
1411  med->SetUniqueID(index++);
1413  }
1414  index = 1;
1415  TIter next2(fShapes);
1416  TGeoShape *shape;
1417  while ((shape=(TGeoShape*)next2())) {
1418  shape->SetUniqueID(index++);
1419  if (shape->IsComposite()) ((TGeoCompositeShape*)shape)->GetBoolNode()->RegisterMatrices();
1420  }
1421 
1422  TIter next3(fMatrices);
1423  TGeoMatrix *matrix;
1424  while ((matrix=(TGeoMatrix*)next3())) {
1425  matrix->RegisterYourself();
1426  }
1427  TIter next4(fMatrices);
1428  index = 1;
1429  while ((matrix=(TGeoMatrix*)next4())) {
1430  matrix->SetUniqueID(index++);
1432  }
1433  TIter next5(fVolumes);
1434  TGeoVolume *vol;
1435  while ((vol=(TGeoVolume*)next5())) vol->UnmarkSaved();
1436 }
1437 
1438 ////////////////////////////////////////////////////////////////////////////////
1439 /// Reset all attributes to default ones. Default attributes for visualization
1440 /// are those defined before closing the geometry.
1441 
1444  if (gPad) delete gPad;
1445  gPad = 0;
1446  SetVisOption(0);
1447  SetVisLevel(3);
1448  SetExplodedView(0);
1449  SetBombFactors();
1450  if (!gStyle) return;
1451  TIter next(fVolumes);
1452  TGeoVolume *vol = 0;
1453  while ((vol=(TGeoVolume*)next())) {
1454  if (!vol->IsVisTouched()) continue;
1455  vol->SetVisTouched(kFALSE);
1456  }
1457 }
1458 ////////////////////////////////////////////////////////////////////////////////
1459 /// Closing geometry implies checking the geometry validity, fixing shapes
1460 /// with negative parameters (run-time shapes)building the cache manager,
1461 /// voxelizing all volumes, counting the total number of physical nodes and
1462 /// registering the manager class to the browser.
1463 
1466  if (fClosed) {
1467  Warning("CloseGeometry", "geometry already closed");
1468  return;
1469  }
1470  if (!fMasterVolume) {
1471  Error("CloseGeometry","you MUST call SetTopVolume() first !");
1472  return;
1473  }
1474  if (!gROOT->GetListOfGeometries()->FindObject(this)) gROOT->GetListOfGeometries()->Add(this);
1475  if (!gROOT->GetListOfBrowsables()->FindObject(this)) gROOT->GetListOfBrowsables()->Add(this);
1476 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1477 // TIter next(brlist);
1478 // TBrowser *browser = 0;
1479 // while ((browser=(TBrowser*)next())) browser->Refresh();
1480  TString opt(option);
1481  opt.ToLower();
1482 // Bool_t dummy = opt.Contains("d");
1483  Bool_t nodeid = opt.Contains("i");
1484  // Create a geometry navigator if not present
1485  TGeoNavigator *nav = 0;
1486  Int_t nnavigators = 0;
1487  // Check if the geometry is streamed from file
1488  if (fIsGeomReading) {
1489  if (fgVerboseLevel>0) Info("CloseGeometry","Geometry loaded from file...");
1491  if (!fElementTable) fElementTable = new TGeoElementTable(200);
1492  if (!fTopNode) {
1493  if (!fMasterVolume) {
1494  Error("CloseGeometry", "Master volume not streamed");
1495  return;
1496  }
1498  if (fStreamVoxels && fgVerboseLevel>0) Info("CloseGeometry","Voxelization retrieved from file");
1499  }
1500  // Create a geometry navigator if not present
1502  nnavigators = GetListOfNavigators()->GetEntriesFast();
1503  Voxelize("ALL");
1504  CountLevels();
1505  for (Int_t i=0; i<nnavigators; i++) {
1506  nav = (TGeoNavigator*)GetListOfNavigators()->At(i);
1507  nav->GetCache()->BuildInfoBranch();
1508  if (nodeid) nav->GetCache()->BuildIdArray();
1509  }
1510  if (!fHashVolumes) {
1511  Int_t nvol = fVolumes->GetEntriesFast();
1512  Int_t ngvol = fGVolumes->GetEntriesFast();
1513  fHashVolumes = new THashList(nvol+1);
1514  fHashGVolumes = new THashList(ngvol+1);
1515  Int_t i;
1516  for (i=0; i<ngvol; i++) fHashGVolumes->AddLast(fGVolumes->At(i));
1517  for (i=0; i<nvol; i++) fHashVolumes->AddLast(fVolumes->At(i));
1518  }
1519  fClosed = kTRUE;
1520  if (fParallelWorld) {
1521  if (fgVerboseLevel>0) Info("CloseGeometry","Recreating parallel world %s ...",fParallelWorld->GetName());
1523  }
1524 
1525  if (fgVerboseLevel>0) Info("CloseGeometry","%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast()-1, GetTitle());
1526  if (fgVerboseLevel>0) Info("CloseGeometry","----------------modeler ready----------------");
1527  return;
1528  }
1529 
1530  // Create a geometry navigator if not present
1532  nnavigators = GetListOfNavigators()->GetEntriesFast();
1534  CheckGeometry();
1535  if (fgVerboseLevel>0) Info("CloseGeometry","Counting nodes...");
1536  fNNodes = CountNodes();
1537  fNLevel = fMasterVolume->CountNodes(1,3)+1;
1538  if (fNLevel<30) fNLevel = 100;
1539 
1540 // BuildIdArray();
1541  Voxelize("ALL");
1542  if (fgVerboseLevel>0) Info("CloseGeometry","Building cache...");
1543  CountLevels();
1544  for (Int_t i=0; i<nnavigators; i++) {
1545  nav = (TGeoNavigator*)GetListOfNavigators()->At(i);
1546  nav->GetCache()->BuildInfoBranch();
1547  if (nodeid) nav->GetCache()->BuildIdArray();
1548  }
1549  fClosed = kTRUE;
1550  if (fgVerboseLevel>0) {
1551  Info("CloseGeometry","%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast()-1, GetTitle());
1552  Info("CloseGeometry","----------------modeler ready----------------");
1553  }
1554 }
1555 
1556 ////////////////////////////////////////////////////////////////////////////////
1557 /// Clear the list of overlaps.
1558 
1561  if (fOverlaps) {
1562  fOverlaps->Delete();
1563  delete fOverlaps;
1564  }
1565  fOverlaps = new TObjArray();
1566 }
1567 
1568 ////////////////////////////////////////////////////////////////////////////////
1569 /// Remove a shape from the list of shapes.
1570 
1571 void TGeoManager::ClearShape(const TGeoShape *shape)
1573  if (fShapes->FindObject(shape)) fShapes->Remove((TGeoShape*)shape);
1574  delete shape;
1575 }
1576 
1577 ////////////////////////////////////////////////////////////////////////////////
1578 /// Clean temporary volumes and shapes from garbage collection.
1579 
1582  if (!fGVolumes && !fGShapes) return;
1583  Int_t i,nentries;
1584  if (fGVolumes) {
1585  nentries = fGVolumes->GetEntries();
1586  TGeoVolume *vol = 0;
1587  for (i=0; i<nentries; i++) {
1588  vol=(TGeoVolume*)fGVolumes->At(i);
1589  if (vol) vol->SetFinder(0);
1590  }
1591  fGVolumes->Delete();
1592  delete fGVolumes;
1593  fGVolumes = 0;
1594  }
1595  if (fGShapes) {
1596  fGShapes->Delete();
1597  delete fGShapes;
1598  fGShapes = 0;
1599  }
1600 }
1601 
1602 ////////////////////////////////////////////////////////////////////////////////
1603 /// Change current path to point to the node having this id.
1604 /// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1605 
1606 void TGeoManager::CdNode(Int_t nodeid)
1608  GetCurrentNavigator()->CdNode(nodeid);
1609 }
1610 
1611 ////////////////////////////////////////////////////////////////////////////////
1612 /// Get the unique ID of the current node.
1613 
1617 }
1618 
1619 ////////////////////////////////////////////////////////////////////////////////
1620 /// Make top level node the current node. Updates the cache accordingly.
1621 /// Determine the overlapping state of current node.
1622 
1623 void TGeoManager::CdTop()
1626 }
1627 
1628 ////////////////////////////////////////////////////////////////////////////////
1629 /// Go one level up in geometry. Updates cache accordingly.
1630 /// Determine the overlapping state of current node.
1631 
1632 void TGeoManager::CdUp()
1635 }
1636 
1637 ////////////////////////////////////////////////////////////////////////////////
1638 /// Make a daughter of current node current. Can be called only with a valid
1639 /// daughter index (no check). Updates cache accordingly.
1640 
1641 void TGeoManager::CdDown(Int_t index)
1643  GetCurrentNavigator()->CdDown(index);
1644 }
1645 
1646 ////////////////////////////////////////////////////////////////////////////////
1647 /// Do a cd to the node found next by FindNextBoundary
1648 
1649 void TGeoManager::CdNext()
1652 }
1653 
1654 ////////////////////////////////////////////////////////////////////////////////
1655 /// Browse the tree of nodes starting from fTopNode according to pathname.
1656 /// Changes the path accordingly.
1657 
1658 Bool_t TGeoManager::cd(const char *path)
1660  return GetCurrentNavigator()->cd(path);
1661 }
1662 
1663 ////////////////////////////////////////////////////////////////////////////////
1664 /// Check if a geometry path is valid without changing the state of the current navigator.
1665 
1666 Bool_t TGeoManager::CheckPath(const char *path) const
1668  return GetCurrentNavigator()->CheckPath(path);
1669 }
1670 
1671 ////////////////////////////////////////////////////////////////////////////////
1672 /// Convert all reflections in geometry to normal rotations + reflected shapes.
1673 
1676  if (!fTopNode) return;
1677  if (fgVerboseLevel>0) Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1678  TGeoIterator next(fTopVolume);
1679  TGeoNode *node;
1680  TGeoNodeMatrix *nodematrix;
1681  TGeoMatrix *matrix, *mclone;
1682  TGeoVolume *reflected;
1683  while ((node=next())) {
1684  matrix = node->GetMatrix();
1685  if (matrix->IsReflection()) {
1686 // printf("%s before\n", node->GetName());
1687 // matrix->Print();
1688  mclone = new TGeoCombiTrans(*matrix);
1689  mclone->RegisterYourself();
1690  // Reflect just the rotation component
1691  mclone->ReflectZ(kFALSE, kTRUE);
1692  nodematrix = (TGeoNodeMatrix*)node;
1693  nodematrix->SetMatrix(mclone);
1694 // printf("%s after\n", node->GetName());
1695 // node->GetMatrix()->Print();
1696  reflected = node->GetVolume()->MakeReflectedVolume();
1697  node->SetVolume(reflected);
1698  }
1699  }
1700  if (fgVerboseLevel>0) Info("ConvertReflections", "Done");
1701 }
1702 
1703 ////////////////////////////////////////////////////////////////////////////////
1704 /// Count maximum number of nodes per volume, maximum depth and maximum
1705 /// number of xtru vertices.
1706 
1709  if (!fTopNode) {
1710  Error("CountLevels", "Top node not defined.");
1711  return;
1712  }
1713  TGeoIterator next(fTopVolume);
1714  Bool_t fixrefs = fIsGeomReading && (fMasterVolume->GetRefCount()==1);
1716  if (fgVerboseLevel>1 && fixrefs) Info("CountLevels", "Fixing volume reference counts");
1717  TGeoNode *node;
1718  Int_t maxlevel = 1;
1719  Int_t maxnodes = fTopVolume->GetNdaughters();
1720  Int_t maxvertices = 1;
1721  while ((node=next())) {
1722  if (fixrefs) {
1723  node->GetVolume()->Grab();
1724  for (Int_t ibit=10; ibit<14; ibit++) {
1725  node->SetBit(BIT(ibit+4), node->TestBit(BIT(ibit)));
1726 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1727  }
1728  }
1729  if (node->GetVolume()->GetVoxels()) {
1730  if (node->GetNdaughters()>maxnodes) maxnodes = node->GetNdaughters();
1731  }
1732  if (next.GetLevel()>maxlevel) maxlevel = next.GetLevel();
1733  if (node->GetVolume()->GetShape()->IsA()==TGeoXtru::Class()) {
1734  TGeoXtru *xtru = (TGeoXtru*)node->GetVolume()->GetShape();
1735  if (xtru->GetNvert()>maxvertices) maxvertices = xtru->GetNvert();
1736  }
1737  }
1738  fgMaxLevel = maxlevel;
1739  fgMaxDaughters = maxnodes;
1740  fgMaxXtruVert = maxvertices;
1741  if (fgVerboseLevel>0) Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1742 }
1743 
1744 ////////////////////////////////////////////////////////////////////////////////
1745 /// Count the total number of nodes starting from a volume, nlevels down.
1746 
1747 Int_t TGeoManager::CountNodes(const TGeoVolume *vol, Int_t nlevels, Int_t option)
1749  TGeoVolume *top;
1750  if (!vol) {
1751  top = fTopVolume;
1752  } else {
1753  top = (TGeoVolume*)vol;
1754  }
1755  Int_t count = top->CountNodes(nlevels, option);
1756  return count;
1757 }
1758 
1759 ////////////////////////////////////////////////////////////////////////////////
1760 /// Set default angles for a given view.
1761 
1765 }
1766 
1767 ////////////////////////////////////////////////////////////////////////////////
1768 /// Draw current point in the same view.
1769 
1772  if (fPainter) fPainter->DrawCurrentPoint(color);
1773 }
1774 
1775 ////////////////////////////////////////////////////////////////////////////////
1776 /// Draw animation of tracks
1777 
1778 void TGeoManager::AnimateTracks(Double_t tmin, Double_t tmax, Int_t nframes, Option_t *option)
1780  SetAnimateTracks();
1781  GetGeomPainter();
1782  if (tmin<0 || tmin>=tmax || nframes<1) return;
1784  box[0] = box[1] = box[2] = 0;
1785  box[3] = box[4] = box[5] = 100;
1786  Double_t dt = (tmax-tmin)/Double_t(nframes);
1787  Double_t delt = 2E-9;
1788  Double_t t = tmin;
1789  Int_t i, j;
1790  TString opt(option);
1791  Bool_t save = kFALSE, geomanim=kFALSE;
1792  TString fname;
1793  if (opt.Contains("/S")) save = kTRUE;
1794 
1795  if (opt.Contains("/G")) geomanim = kTRUE;
1796  SetTminTmax(0,0);
1797  DrawTracks(opt.Data());
1798  Double_t start[6], end[6];
1799  Double_t dd[6] = {0,0,0,0,0,0};
1800  Double_t dlat=0, dlong=0, dpsi=0;
1801  if (geomanim) {
1802  fPainter->EstimateCameraMove(tmin+5*dt, tmin+15*dt, start, end);
1803  for (i=0; i<3; i++) {
1804  start[i+3] = 20 + 1.3*start[i+3];
1805  end[i+3] = 20 + 0.9*end[i+3];
1806  }
1807  for (i=0; i<6; i++) {
1808  dd[i] = (end[i]-start[i])/10.;
1809  }
1810  memcpy(box, start, 6*sizeof(Double_t));
1811  fPainter->GetViewAngles(dlong,dlat,dpsi);
1812  dlong = (-206-dlong)/Double_t(nframes);
1813  dlat = (126-dlat)/Double_t(nframes);
1814  dpsi = (75-dpsi)/Double_t(nframes);
1815  fPainter->GrabFocus();
1816  }
1817 
1818  for (i=0; i<nframes; i++) {
1819  if (t-delt<0) SetTminTmax(t-delt,t);
1820  else gGeoManager->SetTminTmax(t-delt,t);
1821  if (geomanim) {
1822  for (j=0; j<6; j++) box[j]+=dd[j];
1823  fPainter->GrabFocus(1,dlong,dlat,dpsi);
1824  } else {
1825  ModifiedPad();
1826  }
1827  if (save) {
1828  fname = TString::Format("anim%04d.gif", i);
1829  gPad->Print(fname);
1830  }
1831  t += dt;
1832  }
1834 }
1835 
1836 ////////////////////////////////////////////////////////////////////////////////
1837 /// Draw tracks over the geometry, according to option. By default, only
1838 /// primaries are drawn. See TGeoTrack::Draw() for additional options.
1839 
1840 void TGeoManager::DrawTracks(Option_t *option)
1842  TVirtualGeoTrack *track;
1843  //SetVisLevel(1);
1844  //SetVisOption(1);
1845  SetAnimateTracks();
1846  for (Int_t i=0; i<fNtracks; i++) {
1847  track = GetTrack(i);
1848  if (track) track->Draw(option);
1849  }
1851  ModifiedPad();
1852 }
1853 
1854 ////////////////////////////////////////////////////////////////////////////////
1855 /// Draw current path
1856 
1857 void TGeoManager::DrawPath(const char *path, Option_t *option)
1859  if (!fTopVolume) return;
1861  GetGeomPainter()->DrawPath(path, option);
1862 }
1863 
1864 ////////////////////////////////////////////////////////////////////////////////
1865 /// Draw random points in the bounding box of a volume.
1866 
1867 void TGeoManager::RandomPoints(const TGeoVolume *vol, Int_t npoints, Option_t *option)
1869  GetGeomPainter()->RandomPoints((TGeoVolume*)vol, npoints, option);
1870 }
1871 
1872 ////////////////////////////////////////////////////////////////////////////////
1873 /// Check time of finding "Where am I" for n points.
1874 
1875 void TGeoManager::Test(Int_t npoints, Option_t *option)
1877  GetGeomPainter()->Test(npoints, option);
1878 }
1879 
1880 ////////////////////////////////////////////////////////////////////////////////
1881 /// Geometry overlap checker based on sampling.
1882 
1883 void TGeoManager::TestOverlaps(const char* path)
1885  GetGeomPainter()->TestOverlaps(path);
1886 }
1887 
1888 ////////////////////////////////////////////////////////////////////////////////
1889 /// Fill volume names of current branch into an array.
1890 
1891 void TGeoManager::GetBranchNames(Int_t *names) const
1894 }
1895 
1896 ////////////////////////////////////////////////////////////////////////////////
1897 /// Get name for given pdg code;
1898 
1899 const char *TGeoManager::GetPdgName(Int_t pdg) const
1901  static char defaultname[5] = { "XXX" };
1902  if (!fPdgNames || !pdg) return defaultname;
1903  for (Int_t i=0; i<fNpdg; i++) {
1904  if (fPdgId[i]==pdg) return fPdgNames->At(i)->GetName();
1905  }
1906  return defaultname;
1907 }
1908 
1909 ////////////////////////////////////////////////////////////////////////////////
1910 /// Set a name for a particle having a given pdg.
1911 
1912 void TGeoManager::SetPdgName(Int_t pdg, const char *name)
1914  if (!pdg) return;
1915  if (!fPdgNames) {
1916  fPdgNames = new TObjArray(1024);
1917  }
1918  if (!strcmp(name, GetPdgName(pdg))) return;
1919  // store pdg name
1920  if (fNpdg>1023) {
1921  Warning("SetPdgName", "No more than 256 different pdg codes allowed");
1922  return;
1923  }
1924  fPdgId[fNpdg] = pdg;
1925  TNamed *pdgname = new TNamed(name, "");
1926  fPdgNames->AddAtAndExpand(pdgname, fNpdg++);
1927 }
1928 
1929 ////////////////////////////////////////////////////////////////////////////////
1930 /// Fill node copy numbers of current branch into an array.
1931 
1932 void TGeoManager::GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
1934  GetCurrentNavigator()->GetBranchNumbers(copyNumbers, volumeNumbers);
1935 }
1936 
1937 ////////////////////////////////////////////////////////////////////////////////
1938 /// Fill node copy numbers of current branch into an array.
1939 
1940 void TGeoManager::GetBranchOnlys(Int_t *isonly) const
1943 }
1944 
1945 ////////////////////////////////////////////////////////////////////////////////
1946 /// Retrieve cartesian and radial bomb factors.
1947 
1948 void TGeoManager::GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
1950  if (fPainter) {
1951  fPainter->GetBombFactors(bombx, bomby, bombz, bombr);
1952  return;
1953  }
1954  bombx = bomby = bombz = bombr = 1.3;
1955 }
1956 
1957 ////////////////////////////////////////////////////////////////////////////////
1958 /// Return maximum number of daughters of a volume used in the geometry.
1959 
1962  return fgMaxDaughters;
1963 }
1964 
1965 ////////////////////////////////////////////////////////////////////////////////
1966 /// Return maximum number of levels used in the geometry.
1967 
1970  return fgMaxLevel;
1971 }
1972 
1973 ////////////////////////////////////////////////////////////////////////////////
1974 /// Return maximum number of vertices for an xtru shape used.
1975 
1978  return fgMaxXtruVert;
1979 }
1980 
1981 ////////////////////////////////////////////////////////////////////////////////
1982 /// Returns number of threads that were set to use geometry.
1983 
1986  return fgNumThreads;
1987 }
1988 
1989 ////////////////////////////////////////////////////////////////////////////////
1990 /// Return stored current matrix (global matrix of the next touched node).
1991 
1994  if (!GetCurrentNavigator()) return NULL;
1995  return GetCurrentNavigator()->GetHMatrix();
1996 }
1997 
1998 ////////////////////////////////////////////////////////////////////////////////
1999 /// Returns current depth to which geometry is drawn.
2000 
2003  return fVisLevel;
2004 }
2005 
2006 ////////////////////////////////////////////////////////////////////////////////
2007 /// Returns current depth to which geometry is drawn.
2008 
2011  return fVisOption;
2012 }
2013 
2014 ////////////////////////////////////////////////////////////////////////////////
2015 /// Find level of virtuality of current overlapping node (number of levels
2016 /// up having the same tracking media.
2017 
2021 }
2022 
2023 ////////////////////////////////////////////////////////////////////////////////
2024 /// Search the track hierarchy to find the track with the
2025 /// given id
2026 ///
2027 /// if 'primsFirst' is true, then:
2028 /// first tries TGeoManager::GetTrackOfId, then does a
2029 /// recursive search if that fails. this would be faster
2030 /// if the track is somehow known to be a primary
2031 
2034  TVirtualGeoTrack* trk = 0;
2035  trk = GetTrackOfId(id);
2036  if (trk) return trk;
2037  // need recursive search
2038  TIter next(fTracks);
2039  TVirtualGeoTrack* prim;
2040  while ((prim = (TVirtualGeoTrack*)next())) {
2041  trk = prim->FindTrackWithId(id);
2042  if (trk) return trk;
2043  }
2044  return NULL;
2045 }
2046 
2047 ////////////////////////////////////////////////////////////////////////////////
2048 /// Get track with a given ID.
2049 
2052  TVirtualGeoTrack *track;
2053  for (Int_t i=0; i<fNtracks; i++) {
2054  if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2055  if (track->GetId() == id) return track;
2056  }
2057  }
2058  return 0;
2059 }
2060 
2061 ////////////////////////////////////////////////////////////////////////////////
2062 /// Get parent track with a given ID.
2063 
2067  while ((track=track->GetMother())) {
2068  if (track->GetId()==id) return track;
2069  }
2070  return 0;
2071 }
2072 
2073 ////////////////////////////////////////////////////////////////////////////////
2074 /// Get index for track id, -1 if not found.
2075 
2078  TVirtualGeoTrack *track;
2079  for (Int_t i=0; i<fNtracks; i++) {
2080  if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2081  if (track->GetId() == id) return i;
2082  }
2083  }
2084  return -1;
2085 }
2086 
2087 ////////////////////////////////////////////////////////////////////////////////
2088 /// Go upwards the tree until a non-overlapping node
2089 
2092  return GetCurrentNavigator()->GotoSafeLevel();
2093 }
2094 
2095 ////////////////////////////////////////////////////////////////////////////////
2096 /// Go upwards the tree until a non-overlapping node
2097 
2100  return GetCurrentNavigator()->GetSafeLevel();
2101 }
2102 
2103 ////////////////////////////////////////////////////////////////////////////////
2104 /// Set default volume colors according to A of material
2105 
2108  const Int_t nmax = 110;
2109  Int_t col[nmax];
2110  for (Int_t i=0;i<nmax;i++) col[i] = kGray;
2111 
2112  //here we should create a new TColor with the same rgb as in the default
2113  //ROOT colors used below
2114  col[ 3] = kYellow-10;
2115  col[ 4] = col[ 5] = kGreen-10;
2116  col[ 6] = col[ 7] = kBlue-7;
2117  col[ 8] = col[ 9] = kMagenta-3;
2118  col[10] = col[11] = kRed-10;
2119  col[12] = kGray+1;
2120  col[13] = kBlue-10;
2121  col[14] = kOrange+7;
2122  col[16] = kYellow+1;
2123  col[20] = kYellow-10;
2124  col[24] = col[25] = col[26] = kBlue-8;
2125  col[29] = kOrange+9;
2126  col[79] = kOrange-2;
2127 
2128  TGeoVolume *vol;
2129  TIter next(fVolumes);
2130  while ((vol=(TGeoVolume*)next())) {
2131  TGeoMedium *med = vol->GetMedium();
2132  if (!med) continue;
2133  TGeoMaterial *mat = med->GetMaterial();
2134  Int_t matZ = (Int_t)mat->GetZ();
2135  vol->SetLineColor(col[matZ]);
2136  if (mat->GetDensity()<0.1) vol->SetTransparency(60);
2137  }
2138 }
2139 
2140 ////////////////////////////////////////////////////////////////////////////////
2141 /// Compute safe distance from the current point. This represent the distance
2142 /// from POINT to the closest boundary.
2143 
2146  return GetCurrentNavigator()->Safety(inside);
2147 }
2148 
2149 ////////////////////////////////////////////////////////////////////////////////
2150 /// Set volume attributes in G3 style.
2151 
2152 void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2154  TGeoVolume *volume;
2155  Bool_t all = kFALSE;
2156  if (strstr(name,"*")) all=kTRUE;
2157  Int_t ivo=0;
2158  TIter next(fVolumes);
2159  TString chatt = att;
2160  chatt.ToLower();
2161  while ((volume=(TGeoVolume*)next())) {
2162  if (strcmp(volume->GetName(), name) && !all) continue;
2163  ivo++;
2164  if (chatt.Contains("colo")) volume->SetLineColor(val);
2165  if (chatt.Contains("lsty")) volume->SetLineStyle(val);
2166  if (chatt.Contains("lwid")) volume->SetLineWidth(val);
2167  if (chatt.Contains("fill")) volume->SetFillColor(val);
2168  if (chatt.Contains("seen")) volume->SetVisibility(val);
2169  }
2170  TIter next1(fGVolumes);
2171  while ((volume=(TGeoVolume*)next1())) {
2172  if (strcmp(volume->GetName(), name) && !all) continue;
2173  ivo++;
2174  if (chatt.Contains("colo")) volume->SetLineColor(val);
2175  if (chatt.Contains("lsty")) volume->SetLineStyle(val);
2176  if (chatt.Contains("lwid")) volume->SetLineWidth(val);
2177  if (chatt.Contains("fill")) volume->SetFillColor(val);
2178  if (chatt.Contains("seen")) volume->SetVisibility(val);
2179  }
2180  if (!ivo) {
2181  Warning("SetVolumeAttribute","volume: %s does not exist",name);
2182  }
2183 }
2184 
2185 ////////////////////////////////////////////////////////////////////////////////
2186 /// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2187 
2188 void TGeoManager::SetBombFactors(Double_t bombx, Double_t bomby, Double_t bombz, Double_t bombr)
2190  if (fPainter) fPainter->SetBombFactors(bombx, bomby, bombz, bombr);
2191 }
2192 
2193 ////////////////////////////////////////////////////////////////////////////////
2194 /// Set a user-defined shape as clipping for ray tracing.
2195 
2198  TVirtualGeoPainter *painter = GetGeomPainter();
2199  if (shape) {
2201  fClippingShape = shape;
2202  }
2203  painter->SetClippingShape(shape);
2204 }
2205 
2206 ////////////////////////////////////////////////////////////////////////////////
2207 /// set the maximum number of visible nodes.
2208 
2209 void TGeoManager::SetMaxVisNodes(Int_t maxnodes) {
2210  fMaxVisNodes = maxnodes;
2211  if (maxnodes>0 && fgVerboseLevel>0)
2212  Info("SetMaxVisNodes","Automatic visible depth for %d visible nodes", maxnodes);
2213  if (!fPainter) return;
2215  Int_t level = fPainter->GetVisLevel();
2216  if (level != fVisLevel) fVisLevel = level;
2217 }
2218 
2219 ////////////////////////////////////////////////////////////////////////////////
2220 /// make top volume visible on screen
2221 
2224  fPainter->SetTopVisible(vis);
2225 }
2226 
2227 ////////////////////////////////////////////////////////////////////////////////
2228 /// Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
2229 
2232 }
2233 
2234 ////////////////////////////////////////////////////////////////////////////////
2235 /// Set the number of points to be generated on the shape outline when checking
2236 /// for overlaps.
2237 
2238 void TGeoManager::SetNmeshPoints(Int_t npoints)
2240  GetGeomPainter()->SetNmeshPoints(npoints);
2241 }
2242 
2243 ////////////////////////////////////////////////////////////////////////////////
2244 /// set drawing mode :
2245 /// - option=0 (default) all nodes drawn down to vislevel
2246 /// - option=1 leaves and nodes at vislevel drawn
2247 /// - option=2 path is drawn
2248 /// - option=4 visibility changed
2249 
2250 void TGeoManager::SetVisOption(Int_t option) {
2251  if ((option>=0) && (option<3)) fVisOption=option;
2252  if (fPainter) fPainter->SetVisOption(option);
2253 }
2254 
2255 ////////////////////////////////////////////////////////////////////////////////
2256 /// Set visualization option (leaves only OR all volumes)
2257 
2260  if (flag) SetVisOption(1);
2261  else SetVisOption(0);
2262 }
2263 
2264 ////////////////////////////////////////////////////////////////////////////////
2265 /// Set density threshold. Volumes with densities lower than this become
2266 /// transparent.
2267 
2270  fVisDensity = density;
2271  if (fPainter) fPainter->ModifiedPad();
2272 }
2273 
2274 ////////////////////////////////////////////////////////////////////////////////
2275 /// set default level down to which visualization is performed
2276 
2277 void TGeoManager::SetVisLevel(Int_t level) {
2278  if (level>0) {
2279  fVisLevel = level;
2280  fMaxVisNodes = 0;
2281  if (fgVerboseLevel>0)
2282  Info("SetVisLevel","Automatic visible depth disabled");
2284  } else {
2285  SetMaxVisNodes();
2286  }
2287 }
2288 
2289 ////////////////////////////////////////////////////////////////////////////////
2290 /// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2291 
2294  fOverlaps->Sort();
2295 }
2296 
2297 ////////////////////////////////////////////////////////////////////////////////
2298 /// Optimize voxelization type for all volumes. Save best choice in a macro.
2299 
2300 void TGeoManager::OptimizeVoxels(const char *filename)
2302  if (!fTopNode) {
2303  Error("OptimizeVoxels","Geometry must be closed first");
2304  return;
2305  }
2306  std::ofstream out;
2307  TString fname = filename;
2308  if (fname.IsNull()) fname = "tgeovox.C";
2309  out.open(fname, std::ios::out);
2310  if (!out.good()) {
2311  Error("OptimizeVoxels", "cannot open file");
2312  return;
2313  }
2314  // write header
2315  TDatime t;
2316  TString sname(fname);
2317  sname.ReplaceAll(".C", "");
2318  out << sname.Data()<<"()"<<std::endl;
2319  out << "{" << std::endl;
2320  out << "//=== Macro generated by ROOT version "<< gROOT->GetVersion()<<" : "<<t.AsString()<<std::endl;
2321  out << "//=== Voxel optimization for " << GetTitle() << " geometry"<<std::endl;
2322  out << "//===== <run this macro JUST BEFORE closing the geometry>"<<std::endl;
2323  out << " TGeoVolume *vol = 0;"<<std::endl;
2324  out << " // parse all voxelized volumes"<<std::endl;
2325  TGeoVolume *vol = 0;
2326  Bool_t cyltype;
2327  TIter next(fVolumes);
2328  while ((vol=(TGeoVolume*)next())) {
2329  if (!vol->GetVoxels()) continue;
2330  out<<" vol = gGeoManager->GetVolume(\""<<vol->GetName()<<"\");"<<std::endl;
2331  cyltype = vol->OptimizeVoxels();
2332  if (cyltype) {
2333  out<<" vol->SetCylVoxels();"<<std::endl;
2334  } else {
2335  out<<" vol->SetCylVoxels(kFALSE);"<<std::endl;
2336  }
2337  }
2338  out << "}" << std::endl;
2339  out.close();
2340 }
2341 ////////////////////////////////////////////////////////////////////////////////
2342 /// Parse a string boolean expression and do a syntax check. Find top
2343 /// level boolean operator and returns its type. Fill the two
2344 /// substrings to which this operator applies. The returned integer is :
2345 /// - -1 : parse error
2346 /// - 0 : no boolean operator
2347 /// - 1 : union - represented as '+' in expression
2348 /// - 2 : difference (subtraction) - represented as '-' in expression
2349 /// - 3 : intersection - represented as '*' in expression.
2350 /// Parentheses should be used to avoid ambiguities. For instance :
2351 /// - A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2352 /// eliminate not needed parentheses
2353 
2354 Int_t TGeoManager::Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
2356  TString startstr(expr);
2357  Int_t len = startstr.Length();
2358  Int_t i;
2359  TString e0 = "";
2360  expr3 = "";
2361  // eliminate blanks
2362  for (i=0; i< len; i++) {
2363  if (startstr(i)==' ') continue;
2364  e0 += startstr(i, 1);
2365  }
2366  Int_t level = 0;
2367  Int_t levmin = 999;
2368  Int_t boolop = 0;
2369  Int_t indop = 0;
2370  Int_t iloop = 1;
2371  Int_t lastop = 0;
2372  Int_t lastdp = 0;
2373  Int_t lastpp = 0;
2374  Bool_t foundmat = kFALSE;
2375  // check/eliminate parentheses
2376  while (iloop==1) {
2377  iloop = 0;
2378  lastop = 0;
2379  lastdp = 0;
2380  lastpp = 0;
2381  len = e0.Length();
2382  for (i=0; i<len; i++) {
2383  if (e0(i)=='(') {
2384  if (!level) iloop++;
2385  level++;
2386  continue;
2387  }
2388  if (e0(i)==')') {
2389  level--;
2390  if (level==0) lastpp=i;
2391  continue;
2392  }
2393  if ((e0(i)=='+') || (e0(i)=='-') || (e0(i)=='*')) {
2394  lastop = i;
2395  if (level<levmin) {
2396  levmin = level;
2397  indop = i;
2398  }
2399  continue;
2400  }
2401  if ((e0(i)==':') && (level==0)) {
2402  lastdp = i;
2403  continue;
2404  }
2405  }
2406  if (level!=0) {
2407  if (gGeoManager) gGeoManager->Error("Parse","parentheses does not match");
2408  return -1;
2409  }
2410  if (iloop==1 && (e0(0)=='(') && (e0(len-1)==')')) {
2411  // eliminate extra parentheses
2412  e0=e0(1, len-2);
2413  continue;
2414  }
2415  if (foundmat) break;
2416  if (((lastop==0) && (lastdp>0)) || ((lastpp>0) && (lastdp>lastpp) && (indop<lastpp))) {
2417  expr3 = e0(lastdp+1, len-lastdp);
2418  e0=e0(0, lastdp);
2419  foundmat = kTRUE;
2420  iloop = 1;
2421  continue;
2422  } else break;
2423  }
2424  // loop expression and search parentheses/operators
2425  levmin = 999;
2426  for (i=0; i<len; i++) {
2427  if (e0(i)=='(') {
2428  level++;
2429  continue;
2430  }
2431  if (e0(i)==')') {
2432  level--;
2433  continue;
2434  }
2435  // Take LAST operator at lowest level (revision 28/07/08)
2436  if (level<=levmin) {
2437  if (e0(i)=='+') {
2438  boolop = 1; // union
2439  levmin = level;
2440  indop = i;
2441  }
2442  if (e0(i)=='-') {
2443  boolop = 2; // difference
2444  levmin = level;
2445  indop = i;
2446  }
2447  if (e0(i)=='*') {
2448  boolop = 3; // intersection
2449  levmin = level;
2450  indop = i;
2451  }
2452  }
2453  }
2454  if (indop==0) {
2455  expr1=e0;
2456  return indop;
2457  }
2458  expr1 = e0(0, indop);
2459  expr2 = e0(indop+1, len-indop);
2460  return boolop;
2461 }
2462 
2463 
2464 ////////////////////////////////////////////////////////////////////////////////
2465 /// Save current attributes in a macro
2466 
2467 void TGeoManager::SaveAttributes(const char *filename)
2469  if (!fTopNode) {
2470  Error("SaveAttributes","geometry must be closed first\n");
2471  return;
2472  }
2473  std::ofstream out;
2474  TString fname(filename);
2475  if (fname.IsNull()) fname = "tgeoatt.C";
2476  out.open(fname, std::ios::out);
2477  if (!out.good()) {
2478  Error("SaveAttributes", "cannot open file");
2479  return;
2480  }
2481  // write header
2482  TDatime t;
2483  TString sname(fname);
2484  sname.ReplaceAll(".C", "");
2485  out << sname.Data()<<"()"<<std::endl;
2486  out << "{" << std::endl;
2487  out << "//=== Macro generated by ROOT version "<< gROOT->GetVersion()<<" : "<<t.AsString()<<std::endl;
2488  out << "//=== Attributes for " << GetTitle() << " geometry"<<std::endl;
2489  out << "//===== <run this macro AFTER loading the geometry in memory>"<<std::endl;
2490  // save current top volume
2491  out << " TGeoVolume *top = gGeoManager->GetVolume(\""<<fTopVolume->GetName()<<"\");"<<std::endl;
2492  out << " TGeoVolume *vol = 0;"<<std::endl;
2493  out << " TGeoNode *node = 0;"<<std::endl;
2494  out << " // clear all volume attributes and get painter"<<std::endl;
2495  out << " gGeoManager->ClearAttributes();"<<std::endl;
2496  out << " gGeoManager->GetGeomPainter();"<<std::endl;
2497  out << " // set visualization modes and bomb factors"<<std::endl;
2498  out << " gGeoManager->SetVisOption("<<GetVisOption()<<");"<<std::endl;
2499  out << " gGeoManager->SetVisLevel("<<GetVisLevel()<<");"<<std::endl;
2500  out << " gGeoManager->SetExplodedView("<<GetBombMode()<<");"<<std::endl;
2501  Double_t bombx, bomby, bombz, bombr;
2502  GetBombFactors(bombx, bomby, bombz, bombr);
2503  out << " gGeoManager->SetBombFactors("<<bombx<<","<<bomby<<","<<bombz<<","<<bombr<<");"<<std::endl;
2504  out << " // iterate volumes container and set new attributes"<<std::endl;
2505 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2506  TGeoVolume *vol = 0;
2507  fTopNode->SaveAttributes(out);
2508 
2509  TIter next(fVolumes);
2510  while ((vol=(TGeoVolume*)next())) {
2511  vol->SetVisStreamed(kFALSE);
2512  }
2513  out << " // draw top volume with new settings"<<std::endl;
2514  out << " top->Draw();"<<std::endl;
2515  out << " gPad->x3d();"<<std::endl;
2516  out << "}" << std::endl;
2517  out.close();
2518 }
2519 
2520 ////////////////////////////////////////////////////////////////////////////////
2521 /// Returns the deepest node containing fPoint, which must be set a priori.
2522 
2523 TGeoNode *TGeoManager::SearchNode(Bool_t downwards, const TGeoNode *skipnode)
2525  return GetCurrentNavigator()->SearchNode(downwards, skipnode);
2526 }
2527 
2528 ////////////////////////////////////////////////////////////////////////////////
2529 /// Cross next boundary and locate within current node
2530 /// The current point must be on the boundary of fCurrentNode.
2531 
2534  return GetCurrentNavigator()->CrossBoundaryAndLocate(downwards, skipnode);
2535 }
2536 
2537 ////////////////////////////////////////////////////////////////////////////////
2538 /// Compute distance to next boundary within STEPMAX. If no boundary is found,
2539 /// propagate current point along current direction with fStep=STEPMAX. Otherwise
2540 /// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2541 /// node.
2542 
2545  return GetCurrentNavigator()->FindNextBoundaryAndStep(stepmax, compsafe);
2546 }
2547 
2548 ////////////////////////////////////////////////////////////////////////////////
2549 /// Find distance to next boundary and store it in fStep. Returns node to which this
2550 /// boundary belongs. If PATH is specified, compute only distance to the node to which
2551 /// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2552 /// than this value. STEPMAX represent the step to be made imposed by other reasons than
2553 /// geometry (usually physics processes). Therefore in this case this method provides the
2554 /// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2555 /// fStep with a big number.
2556 /// In case frombdr=kTRUE, the isotropic safety is set to zero.
2557 ///
2558 /// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2559 /// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2560 /// they want this computed for the current point.
2561 
2562 TGeoNode *TGeoManager::FindNextBoundary(Double_t stepmax, const char *path, Bool_t frombdr)
2564  // convert current point and direction to local reference
2565  return GetCurrentNavigator()->FindNextBoundary(stepmax,path, frombdr);
2566 }
2567 
2568 ////////////////////////////////////////////////////////////////////////////////
2569 /// Computes as fStep the distance to next daughter of the current volume.
2570 /// The point and direction must be converted in the coordinate system of the current volume.
2571 /// The proposed step limit is fStep.
2572 
2573 TGeoNode *TGeoManager::FindNextDaughterBoundary(Double_t *point, Double_t *dir, Int_t &idaughter, Bool_t compmatrix)
2575  return GetCurrentNavigator()->FindNextDaughterBoundary(point, dir, idaughter, compmatrix);
2576 }
2577 
2578 ////////////////////////////////////////////////////////////////////////////////
2579 /// Reset current state flags.
2580 
2584 }
2585 
2586 ////////////////////////////////////////////////////////////////////////////////
2587 /// Returns deepest node containing current point.
2588 
2591  return GetCurrentNavigator()->FindNode(safe_start);
2592 }
2593 
2594 ////////////////////////////////////////////////////////////////////////////////
2595 /// Returns deepest node containing current point.
2596 
2599  return GetCurrentNavigator()->FindNode(x, y, z);
2600 }
2601 
2602 ////////////////////////////////////////////////////////////////////////////////
2603 /// Computes fast normal to next crossed boundary, assuming that the current point
2604 /// is close enough to the boundary. Works only after calling FindNextBoundary.
2605 
2608  return GetCurrentNavigator()->FindNormalFast();
2609 }
2610 
2611 ////////////////////////////////////////////////////////////////////////////////
2612 /// Computes normal vector to the next surface that will be or was already
2613 /// crossed when propagating on a straight line from a given point/direction.
2614 /// Returns the normal vector cosines in the MASTER coordinate system. The dot
2615 /// product of the normal and the current direction is positive defined.
2616 
2619  return GetCurrentNavigator()->FindNormal(forward);
2620 }
2621 
2622 ////////////////////////////////////////////////////////////////////////////////
2623 /// Checks if point (x,y,z) is still in the current node.
2624 
2627  return GetCurrentNavigator()->IsSameLocation(x,y,z,change);
2628 }
2629 
2630 ////////////////////////////////////////////////////////////////////////////////
2631 /// Check if a new point with given coordinates is the same as the last located one.
2632 
2635  return GetCurrentNavigator()->IsSamePoint(x,y,z);
2636 }
2637 
2638 ////////////////////////////////////////////////////////////////////////////////
2639 /// True if current node is in phi range
2640 
2643  if (!fPhiCut) return kTRUE;
2644  const Double_t *origin;
2646  origin = ((TGeoBBox*)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2647  Double_t point[3];
2648  LocalToMaster(origin, &point[0]);
2649  Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
2650  if (phi<0) phi+=360.;
2651  if ((phi>=fPhimin) && (phi<=fPhimax)) return kFALSE;
2652  return kTRUE;
2653 }
2654 
2655 ////////////////////////////////////////////////////////////////////////////////
2656 /// Initialize current point and current direction vector (normalized)
2657 /// in MARS. Return corresponding node.
2658 
2659 TGeoNode *TGeoManager::InitTrack(const Double_t *point, const Double_t *dir)
2661  return GetCurrentNavigator()->InitTrack(point, dir);
2662 }
2663 
2664 ////////////////////////////////////////////////////////////////////////////////
2665 /// Initialize current point and current direction vector (normalized)
2666 /// in MARS. Return corresponding node.
2667 
2670  return GetCurrentNavigator()->InitTrack(x,y,z,nx,ny,nz);
2671 }
2672 
2673 ////////////////////////////////////////////////////////////////////////////////
2674 /// Inspects path and all flags for the current state.
2675 
2676 void TGeoManager::InspectState() const
2679 }
2680 
2681 ////////////////////////////////////////////////////////////////////////////////
2682 /// Get path to the current node in the form /node0/node1/...
2683 
2684 const char *TGeoManager::GetPath() const
2686  return GetCurrentNavigator()->GetPath();
2687 }
2688 
2689 ////////////////////////////////////////////////////////////////////////////////
2690 /// Get total size of geometry in bytes.
2691 
2694  Int_t count = 0;
2695  TIter next(fVolumes);
2696  TGeoVolume *vol;
2697  while ((vol=(TGeoVolume*)next())) count += vol->GetByteCount();
2698  TIter next1(fMatrices);
2699  TGeoMatrix *matrix;
2700  while ((matrix=(TGeoMatrix*)next1())) count += matrix->GetByteCount();
2701  TIter next2(fMaterials);
2702  TGeoMaterial *mat;
2703  while ((mat=(TGeoMaterial*)next2())) count += mat->GetByteCount();
2704  TIter next3(fMedia);
2705  TGeoMedium *med;
2706  while ((med=(TGeoMedium*)next3())) count += med->GetByteCount();
2707  if (fgVerboseLevel>0) Info("GetByteCount","Total size of logical tree : %i bytes", count);
2708  return count;
2709 }
2710 
2711 ////////////////////////////////////////////////////////////////////////////////
2712 /// Make a default painter if none present. Returns pointer to it.
2713 
2716  if (!fPainter) {
2717  TPluginHandler *h;
2718  if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter"))) {
2719  if (h->LoadPlugin() == -1)
2720  return 0;
2721  fPainter = (TVirtualGeoPainter*)h->ExecPlugin(1,this);
2722  if (!fPainter) {
2723  Error("GetGeomPainter", "could not create painter");
2724  return 0;
2725  }
2726  }
2727  }
2728  return fPainter;
2729 }
2730 
2731 ////////////////////////////////////////////////////////////////////////////////
2732 /// Search for a named volume. All trailing blanks stripped.
2733 
2734 TGeoVolume *TGeoManager::GetVolume(const char *name) const
2736  TString sname = name;
2737  sname = sname.Strip();
2738  TGeoVolume *vol = (TGeoVolume*)fVolumes->FindObject(sname.Data());
2739  return vol;
2740 }
2741 
2742 ////////////////////////////////////////////////////////////////////////////////
2743 /// Fast search for a named volume. All trailing blanks stripped.
2744 
2745 TGeoVolume *TGeoManager::FindVolumeFast(const char *name, Bool_t multi)
2747  if (!fHashVolumes) {
2748  Int_t nvol = fVolumes->GetEntriesFast();
2749  Int_t ngvol = fGVolumes->GetEntriesFast();
2750  fHashVolumes = new THashList(nvol+1);
2751  fHashGVolumes = new THashList(ngvol+1);
2752  Int_t i;
2753  for (i=0; i<ngvol; i++) fHashGVolumes->AddLast(fGVolumes->At(i));
2754  for (i=0; i<nvol; i++) fHashVolumes->AddLast(fVolumes->At(i));
2755  }
2756  TString sname = name;
2757  sname = sname.Strip();
2758  THashList *list = fHashVolumes;
2759  if (multi) list = fHashGVolumes;
2760  TGeoVolume *vol = (TGeoVolume*)list->FindObject(sname.Data());
2761  return vol;
2762 }
2763 
2764 ////////////////////////////////////////////////////////////////////////////////
2765 /// Retrieve unique id for a volume name. Return -1 if name not found.
2766 
2767 Int_t TGeoManager::GetUID(const char *volname) const
2769  TGeoManager *geom = (TGeoManager*)this;
2770  TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
2771  if (!vol) vol = geom->FindVolumeFast(volname, kTRUE);
2772  if (!vol) return -1;
2773  return vol->GetNumber();
2774 }
2775 
2776 ////////////////////////////////////////////////////////////////////////////////
2777 /// Find if a given material duplicates an existing one.
2778 
2781  Int_t index = fMaterials->IndexOf(mat);
2782  if (index <= 0) return 0;
2783  TGeoMaterial *other;
2784  for (Int_t i=0; i<index; i++) {
2785  other = (TGeoMaterial*)fMaterials->At(i);
2786  if (other == mat) continue;
2787  if (other->IsEq(mat)) return other;
2788  }
2789  return 0;
2790 }
2791 
2792 ////////////////////////////////////////////////////////////////////////////////
2793 /// Search for a named material. All trailing blanks stripped.
2794 
2795 TGeoMaterial *TGeoManager::GetMaterial(const char *matname) const
2797  TString sname = matname;
2798  sname = sname.Strip();
2799  TGeoMaterial *mat = (TGeoMaterial*)fMaterials->FindObject(sname.Data());
2800  return mat;
2801 }
2802 
2803 ////////////////////////////////////////////////////////////////////////////////
2804 /// Search for a named tracking medium. All trailing blanks stripped.
2805 
2806 TGeoMedium *TGeoManager::GetMedium(const char *medium) const
2808  TString sname = medium;
2809  sname = sname.Strip();
2810  TGeoMedium *med = (TGeoMedium*)fMedia->FindObject(sname.Data());
2811  return med;
2812 }
2813 
2814 ////////////////////////////////////////////////////////////////////////////////
2815 /// Search for a tracking medium with a given ID.
2816 
2819  TIter next(fMedia);
2820  TGeoMedium *med;
2821  while ((med=(TGeoMedium*)next())) {
2822  if (med->GetId()==numed) return med;
2823  }
2824  return 0;
2825 }
2826 
2827 ////////////////////////////////////////////////////////////////////////////////
2828 /// Return material at position id.
2829 
2832  if (id<0 || id >= fMaterials->GetSize()) return 0;
2833  TGeoMaterial *mat = (TGeoMaterial*)fMaterials->At(id);
2834  return mat;
2835 }
2836 
2837 ////////////////////////////////////////////////////////////////////////////////
2838 /// Return index of named material.
2839 
2840 Int_t TGeoManager::GetMaterialIndex(const char *matname) const
2842  TIter next(fMaterials);
2843  TGeoMaterial *mat;
2844  Int_t id = 0;
2845  TString sname = matname;
2846  sname = sname.Strip();
2847  while ((mat = (TGeoMaterial*)next())) {
2848  if (!strcmp(mat->GetName(),sname.Data()))
2849  return id;
2850  id++;
2851  }
2852  return -1; // fail
2853 }
2854 
2855 ////////////////////////////////////////////////////////////////////////////////
2856 /// Randomly shoot nrays and plot intersections with surfaces for current
2857 /// top node.
2858 
2859 void TGeoManager::RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol, Bool_t check_norm)
2861  GetGeomPainter()->RandomRays(nrays, startx, starty, startz, target_vol, check_norm);
2862 }
2863 
2864 ////////////////////////////////////////////////////////////////////////////////
2865 /// Remove material at given index.
2866 
2869  TObject *obj = fMaterials->At(index);
2870  if (obj) fMaterials->Remove(obj);
2871 }
2872 
2873 ////////////////////////////////////////////////////////////////////////////////
2874 /// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
2875 /// from geometry. Deletion has to be managed by users.
2876 
2879  TIter next(fVolumes);
2880  TGeoVolume *vol;
2881  while ((vol=(TGeoVolume*)next())) vol->SetField(0);
2882 }
2883 
2884 ////////////////////////////////////////////////////////////////////////////////
2885 /// Change raytracing mode.
2886 
2887 void TGeoManager::SetRTmode(Int_t mode)
2889  fRaytraceMode = mode;
2891 }
2892 
2893 ////////////////////////////////////////////////////////////////////////////////
2894 /// Restore the master volume of the geometry.
2895 
2898  if (fTopVolume == fMasterVolume) return;
2900 }
2901 
2902 ////////////////////////////////////////////////////////////////////////////////
2903 /// Voxelize all non-divided volumes.
2904 
2905 void TGeoManager::Voxelize(Option_t *option)
2907  TGeoVolume *vol;
2908 // TGeoVoxelFinder *vox = 0;
2909  if (!fStreamVoxels && fgVerboseLevel>0) Info("Voxelize","Voxelizing...");
2910 // Int_t nentries = fVolumes->GetSize();
2911  TIter next(fVolumes);
2912  while ((vol = (TGeoVolume*)next())) {
2913  if (!fIsGeomReading) vol->SortNodes();
2914  if (!fStreamVoxels) {
2915  vol->Voxelize(option);
2916  }
2917  if (!fIsGeomReading) vol->FindOverlaps();
2918  }
2919 }
2920 
2921 ////////////////////////////////////////////////////////////////////////////////
2922 /// Send "Modified" signal to painter.
2923 
2924 void TGeoManager::ModifiedPad() const
2926  if (!fPainter) return;
2927  fPainter->ModifiedPad();
2928 }
2929 
2930 ////////////////////////////////////////////////////////////////////////////////
2931 /// Make an TGeoArb8 volume.
2932 
2933 TGeoVolume *TGeoManager::MakeArb8(const char *name, TGeoMedium *medium,
2934  Double_t dz, Double_t *vertices)
2935 {
2936  return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
2937 }
2938 
2939 ////////////////////////////////////////////////////////////////////////////////
2940 /// Make in one step a volume pointing to a box shape with given medium.
2941 
2942 TGeoVolume *TGeoManager::MakeBox(const char *name, TGeoMedium *medium,
2944 {
2945  return TGeoBuilder::Instance(this)->MakeBox(name, medium, dx, dy, dz);
2946 }
2947 
2948 ////////////////////////////////////////////////////////////////////////////////
2949 /// Make in one step a volume pointing to a parallelepiped shape with given medium.
2950 
2951 TGeoVolume *TGeoManager::MakePara(const char *name, TGeoMedium *medium,
2953  Double_t alpha, Double_t theta, Double_t phi)
2954 {
2955  return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
2956 }
2957 
2958 ////////////////////////////////////////////////////////////////////////////////
2959 /// Make in one step a volume pointing to a sphere shape with given medium
2960 
2961 TGeoVolume *TGeoManager::MakeSphere(const char *name, TGeoMedium *medium,
2962  Double_t rmin, Double_t rmax, Double_t themin, Double_t themax,
2963  Double_t phimin, Double_t phimax)
2964 {
2965  return TGeoBuilder::Instance(this)->MakeSphere(name, medium, rmin, rmax, themin, themax, phimin, phimax);
2966 }
2967 
2968 ////////////////////////////////////////////////////////////////////////////////
2969 /// Make in one step a volume pointing to a torus shape with given medium.
2970 
2972  Double_t rmin, Double_t rmax, Double_t phi1, Double_t dphi)
2973 {
2974  return TGeoBuilder::Instance(this)->MakeTorus(name, medium, r, rmin, rmax, phi1, dphi);
2975 }
2976 
2977 ////////////////////////////////////////////////////////////////////////////////
2978 /// Make in one step a volume pointing to a tube shape with given medium.
2979 
2980 TGeoVolume *TGeoManager::MakeTube(const char *name, TGeoMedium *medium,
2981  Double_t rmin, Double_t rmax, Double_t dz)
2982 {
2983  return TGeoBuilder::Instance(this)->MakeTube(name, medium, rmin, rmax, dz);
2984 }
2985 
2986 ////////////////////////////////////////////////////////////////////////////////
2987 /// Make in one step a volume pointing to a tube segment shape with given medium.
2988 /// The segment will be from phiStart to phiEnd, the angles are expressed in degree
2989 
2990 TGeoVolume *TGeoManager::MakeTubs(const char *name, TGeoMedium *medium,
2991  Double_t rmin, Double_t rmax, Double_t dz,
2992  Double_t phiStart, Double_t phiEnd)
2993 {
2994  return TGeoBuilder::Instance(this)->MakeTubs(name, medium, rmin, rmax, dz, phiStart, phiEnd);
2995 }
2996 
2997 ////////////////////////////////////////////////////////////////////////////////
2998 /// Make in one step a volume pointing to a tube shape with given medium
2999 
3000 TGeoVolume *TGeoManager::MakeEltu(const char *name, TGeoMedium *medium,
3002 {
3003  return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
3004 }
3005 
3006 ////////////////////////////////////////////////////////////////////////////////
3007 /// Make in one step a volume pointing to a tube shape with given medium
3008 
3009 TGeoVolume *TGeoManager::MakeHype(const char *name, TGeoMedium *medium,
3010  Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
3011 {
3012  return TGeoBuilder::Instance(this)->MakeHype(name, medium, rin, stin, rout, stout, dz);
3013 }
3014 
3015 ////////////////////////////////////////////////////////////////////////////////
3016 /// Make in one step a volume pointing to a tube shape with given medium
3017 
3020 {
3021  return TGeoBuilder::Instance(this)->MakeParaboloid(name, medium, rlo, rhi, dz);
3022 }
3023 
3024 ////////////////////////////////////////////////////////////////////////////////
3025 /// Make in one step a volume pointing to a tube segment shape with given medium
3026 
3027 TGeoVolume *TGeoManager::MakeCtub(const char *name, TGeoMedium *medium,
3028  Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2,
3029  Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
3030 {
3031  return TGeoBuilder::Instance(this)->MakeCtub(name, medium, rmin, rmax, dz, phi1, phi2, lx, ly, lz, tx, ty, tz);
3032 }
3033 
3034 ////////////////////////////////////////////////////////////////////////////////
3035 /// Make in one step a volume pointing to a cone shape with given medium.
3036 
3037 TGeoVolume *TGeoManager::MakeCone(const char *name, TGeoMedium *medium,
3038  Double_t dz, Double_t rmin1, Double_t rmax1,
3039  Double_t rmin2, Double_t rmax2)
3040 {
3041  return TGeoBuilder::Instance(this)->MakeCone(name, medium, dz, rmin1, rmax1, rmin2, rmax2);
3042 }
3043 
3044 ////////////////////////////////////////////////////////////////////////////////
3045 /// Make in one step a volume pointing to a cone segment shape with given medium
3046 
3047 TGeoVolume *TGeoManager::MakeCons(const char *name, TGeoMedium *medium,
3048  Double_t dz, Double_t rmin1, Double_t rmax1,
3049  Double_t rmin2, Double_t rmax2,
3050  Double_t phi1, Double_t phi2)
3051 {
3052  return TGeoBuilder::Instance(this)->MakeCons(name, medium, dz, rmin1, rmax1, rmin2, rmax2, phi1, phi2);
3053 }
3054 
3055 ////////////////////////////////////////////////////////////////////////////////
3056 /// Make in one step a volume pointing to a polycone shape with given medium.
3057 
3058 TGeoVolume *TGeoManager::MakePcon(const char *name, TGeoMedium *medium,
3059  Double_t phi, Double_t dphi, Int_t nz)
3060 {
3061  return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3062 }
3063 
3064 ////////////////////////////////////////////////////////////////////////////////
3065 /// Make in one step a volume pointing to a polygone shape with given medium.
3066 
3067 TGeoVolume *TGeoManager::MakePgon(const char *name, TGeoMedium *medium,
3068  Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
3069 {
3070  return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3071 }
3072 
3073 ////////////////////////////////////////////////////////////////////////////////
3074 /// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3075 
3076 TGeoVolume *TGeoManager::MakeTrd1(const char *name, TGeoMedium *medium,
3078 {
3079  return TGeoBuilder::Instance(this)->MakeTrd1(name, medium, dx1, dx2, dy, dz);
3080 }
3081 
3082 ////////////////////////////////////////////////////////////////////////////////
3083 /// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3084 
3085 TGeoVolume *TGeoManager::MakeTrd2(const char *name, TGeoMedium *medium,
3086  Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2,
3087  Double_t dz)
3088 {
3089  return TGeoBuilder::Instance(this)->MakeTrd2(name, medium, dx1, dx2, dy1, dy2, dz);
3090 }
3091 
3092 ////////////////////////////////////////////////////////////////////////////////
3093 /// Make in one step a volume pointing to a trapezoid shape with given medium.
3094 
3095 TGeoVolume *TGeoManager::MakeTrap(const char *name, TGeoMedium *medium,
3097  Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
3098  Double_t tl2, Double_t alpha2)
3099 {
3100  return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2, alpha2);
3101 }
3102 
3103 ////////////////////////////////////////////////////////////////////////////////
3104 /// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3105 
3106 TGeoVolume *TGeoManager::MakeGtra(const char *name, TGeoMedium *medium,
3107  Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1,
3108  Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
3109  Double_t tl2, Double_t alpha2)
3110 {
3111  return TGeoBuilder::Instance(this)->MakeGtra(name, medium, dz, theta, phi, twist, h1, bl1, tl1, alpha1, h2, bl2, tl2, alpha2);
3112 }
3113 
3114 ////////////////////////////////////////////////////////////////////////////////
3115 /// Make a TGeoXtru-shaped volume with nz planes
3116 
3117 TGeoVolume *TGeoManager::MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
3119  return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3120 }
3121 
3122 ////////////////////////////////////////////////////////////////////////////////
3123 /// Creates an alignable object with unique name corresponding to a path
3124 /// and adds it to the list of alignables. An optional unique ID can be
3125 /// provided, in which case PN entries can be searched fast by uid.
3126 
3127 TGeoPNEntry *TGeoManager::SetAlignableEntry(const char *unique_name, const char *path,
3128  Int_t uid)
3129 {
3130  if (!CheckPath(path)) return NULL;
3131  if (!fHashPNE) fHashPNE = new THashList(256,3);
3132  if (!fArrayPNE) fArrayPNE = new TObjArray(256);
3133  TGeoPNEntry *entry = GetAlignableEntry(unique_name);
3134  if (entry) {
3135  Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3136  return 0;
3137  }
3138  entry = new TGeoPNEntry(unique_name, path);
3139  Int_t ientry = fHashPNE->GetSize();
3140  fHashPNE->Add(entry);
3141  fArrayPNE->AddAtAndExpand(entry, ientry);
3142  if (uid>=0) {
3143  Bool_t added = InsertPNEId(uid, ientry);
3144  if (!added) Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3145  }
3146  return entry;
3147 }
3148 
3149 ////////////////////////////////////////////////////////////////////////////////
3150 /// Retrieves an existing alignable object.
3151 
3154  if (!fHashPNE) return 0;
3155  return (TGeoPNEntry*)fHashPNE->FindObject(name);
3156 }
3157 
3158 ////////////////////////////////////////////////////////////////////////////////
3159 /// Retrieves an existing alignable object at a given index.
3160 
3163  if (!fArrayPNE && !InitArrayPNE()) return 0;
3164  return (TGeoPNEntry*)fArrayPNE->At(index);
3165 }
3166 
3167 ////////////////////////////////////////////////////////////////////////////////
3168 /// Retrieves an existing alignable object having a preset UID.
3169 
3172  if (!fNPNEId || (!fArrayPNE && !InitArrayPNE())) return NULL;
3173  Int_t index = TMath::BinarySearch(fNPNEId, fKeyPNEId, uid);
3174  if (index<0 || fKeyPNEId[index]!=uid) return NULL;
3175  return (TGeoPNEntry*)fArrayPNE->At(fValuePNEId[index]);
3176 }
3177 
3178 ////////////////////////////////////////////////////////////////////////////////
3179 /// Retrieves number of PN entries with or without UID.
3180 
3181 Int_t TGeoManager::GetNAlignable(Bool_t with_uid) const
3183  if (!fHashPNE) return 0;
3184  if (with_uid) return fNPNEId;
3185  return fHashPNE->GetSize();
3186 }
3187 
3188 ////////////////////////////////////////////////////////////////////////////////
3189 /// Insert a PN entry in the sorted array of indexes.
3190 
3193  if (!fSizePNEId) {
3194  // Create the arrays.
3195  fSizePNEId = 128;
3196  fKeyPNEId = new Int_t[fSizePNEId];
3197  memset(fKeyPNEId, 0, fSizePNEId*sizeof(Int_t));
3198  fValuePNEId = new Int_t[fSizePNEId];
3199  memset(fValuePNEId, 0, fSizePNEId*sizeof(Int_t));
3200  fKeyPNEId[fNPNEId] = uid;
3201  fValuePNEId[fNPNEId++] = ientry;
3202  return kTRUE;
3203  }
3204  // Search id in the existing array and return false if it already exists.
3205  Int_t index = TMath::BinarySearch(fNPNEId, fKeyPNEId, uid);
3206  if (index>0 && fKeyPNEId[index]==uid) return kFALSE;
3207  // Resize the arrays and insert the value
3208  Bool_t resize = (fNPNEId==fSizePNEId)?kTRUE:kFALSE;
3209  if (resize) {
3210  // Double the size of the array
3211  fSizePNEId *= 2;
3212  // Create new arrays of keys and values
3213  Int_t *keys = new Int_t[fSizePNEId];
3214  memset(keys, 0, fSizePNEId*sizeof(Int_t));
3215  Int_t *values = new Int_t[fSizePNEId];
3216  memset(values, 0, fSizePNEId*sizeof(Int_t));
3217  // Copy all keys<uid in the new keys array (0 to index)
3218  memcpy(keys, fKeyPNEId, (index+1)*sizeof(Int_t));
3219  memcpy(values, fValuePNEId, (index+1)*sizeof(Int_t));
3220  // Insert current key at index+1
3221  keys[index+1] = uid;
3222  values[index+1] = ientry;
3223  // Copy all remaining keys from the old to new array
3224  memcpy(&keys[index+2], &fKeyPNEId[index+1], (fNPNEId-index-1)*sizeof(Int_t));
3225  memcpy(&values[index+2], &fValuePNEId[index+1], (fNPNEId-index-1)*sizeof(Int_t));
3226  delete [] fKeyPNEId;
3227  fKeyPNEId = keys;
3228  delete [] fValuePNEId;
3229  fValuePNEId = values;
3230  fNPNEId++;
3231  return kTRUE;
3232  }
3233  // Insert the value in the existing arrays
3234  Int_t i;
3235  for (i=fNPNEId-1; i>index; i--) {
3236  fKeyPNEId[i+1] = fKeyPNEId[i];
3237  fValuePNEId[i+1] = fValuePNEId[i];
3238  }
3239  fKeyPNEId[index+1] = uid;
3240  fValuePNEId[index+1] = ientry;
3241  fNPNEId++;
3242  return kTRUE;
3243 }
3244 
3245 ////////////////////////////////////////////////////////////////////////////////
3246 /// Make a physical node from the path pointed by an alignable object with a given name.
3247 
3250  TGeoPNEntry *entry = GetAlignableEntry(name);
3251  if (!entry) {
3252  Error("MakeAlignablePN","No alignable object named %s found !", name);
3253  return 0;
3254  }
3255  return MakeAlignablePN(entry);
3256 }
3257 
3258 ////////////////////////////////////////////////////////////////////////////////
3259 /// Make a physical node from the path pointed by a given alignable object.
3260 
3263  if (!entry) {
3264  Error("MakeAlignablePN","No alignable object specified !");
3265  return 0;
3266  }
3267  const char *path = entry->GetTitle();
3268  if (!cd(path)) {
3269  Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s",
3270  entry->GetName(), path);
3271  return 0;
3272  }
3273  TGeoPhysicalNode *node = MakePhysicalNode(path);
3274  entry->SetPhysicalNode(node);
3275  return node;
3276 }
3277 
3278 ////////////////////////////////////////////////////////////////////////////////
3279 /// Makes a physical node corresponding to a path. If PATH is not specified,
3280 /// makes physical node matching current modeller state.
3281 
3284  TGeoPhysicalNode *node;
3285  if (path) {
3286  if (!CheckPath(path)) {
3287  Error("MakePhysicalNode", "path: %s not valid", path);
3288  return NULL;
3289  }
3290  node = new TGeoPhysicalNode(path);
3291  } else {
3292  node = new TGeoPhysicalNode(GetPath());
3293  }
3294  fPhysicalNodes->Add(node);
3295  return node;
3296 }
3297 
3298 ////////////////////////////////////////////////////////////////////////////////
3299 /// Refresh physical nodes to reflect the actual geometry paths after alignment
3300 /// was applied. Optionally locks physical nodes (default).
3301 
3304  TIter next(gGeoManager->GetListOfPhysicalNodes());
3305  TGeoPhysicalNode *pn;
3306  while ((pn=(TGeoPhysicalNode*)next())) pn->Refresh();
3308  if (lock) LockGeometry();
3309 }
3310 
3311 ////////////////////////////////////////////////////////////////////////////////
3312 /// Clear the current list of physical nodes, so that we can start over with a new list.
3313 /// If MUSTDELETE is true, delete previous nodes.
3314 
3315 void TGeoManager::ClearPhysicalNodes(Bool_t mustdelete)
3317  if (mustdelete) fPhysicalNodes->Delete();
3318  else fPhysicalNodes->Clear();
3319 }
3320 
3321 ////////////////////////////////////////////////////////////////////////////////
3322 /// Make an assembly of volumes.
3323 
3326  return TGeoBuilder::Instance(this)->MakeVolumeAssembly(name);
3327 }
3328 
3329 ////////////////////////////////////////////////////////////////////////////////
3330 /// Make a TGeoVolumeMulti handling a list of volumes.
3331 
3334  return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3335 }
3336 
3337 ////////////////////////////////////////////////////////////////////////////////
3338 /// Set type of exploding view (see TGeoPainter::SetExplodedView())
3339 
3342  if ((ibomb>=0) && (ibomb<4)) fExplodedView = ibomb;
3343  if (fPainter) fPainter->SetExplodedView(ibomb);
3344 }
3345 
3346 ////////////////////////////////////////////////////////////////////////////////
3347 /// Set cut phi range
3348 
3349 void TGeoManager::SetPhiRange(Double_t phimin, Double_t phimax)
3351  if ((phimin==0) && (phimax==360)) {
3352  fPhiCut = kFALSE;
3353  return;
3354  }
3355  fPhiCut = kTRUE;
3356  fPhimin = phimin;
3357  fPhimax = phimax;
3358 }
3359 
3360 ////////////////////////////////////////////////////////////////////////////////
3361 /// Set number of segments for approximating circles in drawing.
3362 
3365  if (fNsegments==nseg) return;
3366  if (nseg>2) fNsegments = nseg;
3367  if (fPainter) fPainter->SetNsegments(nseg);
3368 }
3369 
3370 ////////////////////////////////////////////////////////////////////////////////
3371 /// Get number of segments approximating circles
3372 
3375  return fNsegments;
3376 }
3377 
3378 ////////////////////////////////////////////////////////////////////////////////
3379 /// Now just a shortcut for GetElementTable.
3380 
3383  GetElementTable();
3385 }
3386 
3387 ////////////////////////////////////////////////////////////////////////////////
3388 /// Returns material table. Creates it if not existing.
3389 
3392  if (!fElementTable) fElementTable = new TGeoElementTable(200);
3393  return fElementTable;
3394 }
3395 
3396 ////////////////////////////////////////////////////////////////////////////////
3397 /// Make a rectilinear step of length fStep from current point (fPoint) on current
3398 /// direction (fDirection). If the step is imposed by geometry, is_geom flag
3399 /// must be true (default). The cross flag specifies if the boundary should be
3400 /// crossed in case of a geometry step (default true). Returns new node after step.
3401 /// Set also on boundary condition.
3402 
3403 TGeoNode *TGeoManager::Step(Bool_t is_geom, Bool_t cross)
3405  return GetCurrentNavigator()->Step(is_geom, cross);
3406 }
3407 
3408 ////////////////////////////////////////////////////////////////////////////////
3409 /// shoot npoints randomly in a box of 1E-5 around current point.
3410 /// return minimum distance to points outside
3411 
3413  const char* g3path)
3414 {
3415  return GetGeomPainter()->SamplePoints(npoints, dist, epsil, g3path);
3416 }
3417 
3418 ////////////////////////////////////////////////////////////////////////////////
3419 /// Set the top volume and corresponding node as starting point of the geometry.
3420 
3423  if (fTopVolume==vol) return;
3424 
3425  TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3426  TIter next(brlist);
3427  TBrowser *browser = 0;
3428 
3429  if (fTopVolume) fTopVolume->SetTitle("");
3430  fTopVolume = vol;
3431  vol->SetTitle("Top volume");
3432  if (fTopNode) {
3433  TGeoNode *topn = fTopNode;
3434  fTopNode = 0;
3435  while ((browser=(TBrowser*)next())) browser->RecursiveRemove(topn);
3436  delete topn;
3437  } else {
3438  fMasterVolume = vol;
3439  fMasterVolume->Grab();
3441  if (fgVerboseLevel>0) Info("SetTopVolume","Top volume is %s. Master volume is %s", fTopVolume->GetName(),
3442  fMasterVolume->GetName());
3443  }
3444 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3445 // fCurrentMatrix->Print();
3446  fTopNode = new TGeoNodeMatrix(vol, gGeoIdentity);
3447  fTopNode->SetName(TString::Format("%s_1",vol->GetName()));
3448  fTopNode->SetNumber(1);
3449  fTopNode->SetTitle("Top logical node");
3450  fNodes->AddAt(fTopNode, 0);
3451  if (!GetCurrentNavigator()) {
3453  return;
3454  }
3455  Int_t nnavigators = 0;
3457  if (!arr) return;
3458  nnavigators = arr->GetEntriesFast();
3459  for (Int_t i=0; i<nnavigators; i++) {
3460  TGeoNavigator *nav = (TGeoNavigator*)arr->At(i);
3461  nav->ResetAll();
3462  if (fClosed) nav->GetCache()->BuildInfoBranch();
3463  }
3464 }
3465 
3466 ////////////////////////////////////////////////////////////////////////////////
3467 /// Define different tracking media.
3468 
3471 /*
3472  Int_t nmat = fMaterials->GetSize();
3473  if (!nmat) {printf(" No materials !\n"); return;}
3474  Int_t *media = new Int_t[nmat];
3475  memset(media, 0, nmat*sizeof(Int_t));
3476  Int_t imedia = 1;
3477  TGeoMaterial *mat, *matref;
3478  mat = (TGeoMaterial*)fMaterials->At(0);
3479  if (mat->GetMedia()) {
3480  for (Int_t i=0; i<nmat; i++) {
3481  mat = (TGeoMaterial*)fMaterials->At(i);
3482  mat->Print();
3483  }
3484  return;
3485  }
3486  mat->SetMedia(imedia);
3487  media[0] = imedia++;
3488  mat->Print();
3489  for (Int_t i=0; i<nmat; i++) {
3490  mat = (TGeoMaterial*)fMaterials->At(i);
3491  for (Int_t j=0; j<i; j++) {
3492  matref = (TGeoMaterial*)fMaterials->At(j);
3493  if (mat->IsEq(matref)) {
3494  mat->SetMedia(media[j]);
3495  break;
3496  }
3497  if (j==(i-1)) {
3498  // different material
3499  mat->SetMedia(imedia);
3500  media[i] = imedia++;
3501  mat->Print();
3502  }
3503  }
3504  }
3505 */
3506 }
3507 
3508 ////////////////////////////////////////////////////////////////////////////////
3509 /// Check pushes and pulls needed to cross the next boundary with respect to the
3510 /// position given by FindNextBoundary. If radius is not mentioned the full bounding
3511 /// box will be sampled.
3512 
3513 void TGeoManager::CheckBoundaryErrors(Int_t ntracks, Double_t radius)
3515  GetGeomPainter()->CheckBoundaryErrors(ntracks, radius);
3516 }
3517 
3518 ////////////////////////////////////////////////////////////////////////////////
3519 /// Check the boundary errors reference file created by CheckBoundaryErrors method.
3520 /// The shape for which the crossing failed is drawn with the starting point in red
3521 /// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3522 
3526 }
3527 
3528 ////////////////////////////////////////////////////////////////////////////////
3529 /// Classify a given point. See TGeoChecker::CheckPoint().
3530 
3533  GetGeomPainter()->CheckPoint(x,y,z,option);
3534 }
3535 
3536 ////////////////////////////////////////////////////////////////////////////////
3537 /// Test for shape navigation methods. Summary for test numbers:
3538 /// - 1: DistFromInside/Outside. Sample points inside the shape. Generate
3539 /// directions randomly in cos(theta). Compute DistFromInside and move the
3540 /// point with bigger distance. Compute DistFromOutside back from new point.
3541 /// Plot d-(d1+d2)
3542 ///
3543 
3544 void TGeoManager::CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)
3546  GetGeomPainter()->CheckShape(shape, testNo, nsamples, option);
3547 }
3548 
3549 ////////////////////////////////////////////////////////////////////////////////
3550 /// Geometry checking.
3551 /// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3552 /// - if option contains 'b': Optional boundary crossing check + timing per volume.
3553 ///
3554 /// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3555 /// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3556 /// be called for the suspicious volumes.
3557 ///
3558 /// STAGE 2: normal overlap checking using the shapes mesh - fills the list of
3559 /// overlaps.
3560 ///
3561 /// STAGE 3: shooting NRAYS rays from VERTEX and counting the total number of
3562 /// crossings per volume (rays propagated from boundary to boundary until
3563 /// geometry exit). Timing computed and results stored in a histo.
3564 ///
3565 /// STAGE 4: shooting 1 mil. random rays inside EACH volume and calling
3566 /// FindNextBoundary() + Safety() for each call. The timing is normalized by the
3567 /// number of crossings computed at stage 2 and presented as percentage.
3568 /// One can get a picture on which are the most "burned" volumes during
3569 /// transportation from geometry point of view. Another plot of the timing per
3570 /// volume vs. number of daughters is produced.
3571 
3572 void TGeoManager::CheckGeometryFull(Int_t ntracks, Double_t vx, Double_t vy, Double_t vz, Option_t *option)
3574  TString opt(option);
3575  opt.ToLower();
3576  if (!opt.Length()) {
3577  Error("CheckGeometryFull","The option string must contain a letter. See method documentation.");
3578  return;
3579  }
3580  Bool_t checkoverlaps = opt.Contains("o");
3581  Bool_t checkcrossings = opt.Contains("b");
3582  Double_t vertex[3];
3583  vertex[0] = vx;
3584  vertex[1] = vy;
3585  vertex[2] = vz;
3586  GetGeomPainter()->CheckGeometryFull(checkoverlaps,checkcrossings,ntracks,vertex);
3587 }
3588 
3589 ////////////////////////////////////////////////////////////////////////////////
3590 /// Perform last checks on the geometry
3591 
3592 void TGeoManager::CheckGeometry(Option_t * /*option*/)
3594  if (fgVerboseLevel>0) Info("CheckGeometry","Fixing runtime shapes...");
3595  TIter next(fShapes);
3596  TIter nextv(fVolumes);
3597  TGeoShape *shape;
3598  TGeoVolume *vol;
3599  Bool_t has_runtime = kFALSE;
3600  while ((shape = (TGeoShape*)next())) {
3601  if (shape->IsRunTimeShape()) {
3602  has_runtime = kTRUE;
3603  }
3604  if (fIsGeomReading) shape->AfterStreamer();
3606  if (!shape->TestShapeBit(TGeoShape::kGeoClosedShape)) shape->ComputeBBox();
3607  }
3608  if (has_runtime) fTopNode->CheckShapes();
3609  else if (fgVerboseLevel>0) Info("CheckGeometry","...Nothing to fix");
3610  // Compute bounding box for assemblies
3612  while ((vol = (TGeoVolume*)nextv())) {
3613  if (vol->IsAssembly()) vol->GetShape()->ComputeBBox();
3614  else if (vol->GetMedium() == dummy) {
3615  Warning("CheckGeometry", "Volume \"%s\" has no medium: assigned dummy medium and material", vol->GetName());
3616  vol->SetMedium(dummy);
3617  }
3618  }
3619 }
3620 
3621 ////////////////////////////////////////////////////////////////////////////////
3622 /// Check all geometry for illegal overlaps within a limit OVLP.
3623 
3624 void TGeoManager::CheckOverlaps(Double_t ovlp, Option_t * option)
3626  if (!fTopNode) {
3627  Error("CheckOverlaps","Top node not set");
3628  return;
3629  }
3630  fTopNode->CheckOverlaps(ovlp,option);
3631 }
3632 
3633 ////////////////////////////////////////////////////////////////////////////////
3634 /// Prints the current list of overlaps.
3635 
3636 void TGeoManager::PrintOverlaps() const
3638  if (!fOverlaps) return;
3639  Int_t novlp = fOverlaps->GetEntriesFast();
3640  if (!novlp) return;
3641  TGeoManager *geom = (TGeoManager*)this;
3642  geom->GetGeomPainter()->PrintOverlaps();
3643 }
3644 
3645 ////////////////////////////////////////////////////////////////////////////////
3646 /// Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
3647 /// Option can be "v" - verbose (default)
3648 
3649 Double_t TGeoManager::Weight(Double_t precision, Option_t *option)
3651  GetGeomPainter();
3652  TString opt(option);
3653  opt.ToLower();
3654  Double_t weight;
3655  TGeoVolume *volume = fTopVolume;
3656  if (opt.Contains("v")) {
3657  if (opt.Contains("a")) {
3658  if (fgVerboseLevel>0) Info("Weight", "Computing analytically weight of %s", volume->GetName());
3659  weight = volume->WeightA();
3660  if (fgVerboseLevel>0) Info("Weight", "Computed weight: %f [kg]\n", weight);
3661  return weight;
3662  }
3663  if (fgVerboseLevel>0) {
3664  Info("Weight", "Estimating weight of %s with %g %% precision", fTopVolume->GetName(), 100.*precision);
3665  printf(" event weight err\n");
3666  printf("========================================\n");
3667  }
3668  }
3669  weight = fPainter->Weight(precision, option);
3670  return weight;
3671 }
3672 
3673 ////////////////////////////////////////////////////////////////////////////////
3674 /// computes the total size in bytes of the branch starting with node.
3675 /// The option can specify if all the branch has to be parsed or only the node
3676 
3677 ULong_t TGeoManager::SizeOf(const TGeoNode * /*node*/, Option_t * /*option*/)
3679  return 0;
3680 }
3681 
3682 ////////////////////////////////////////////////////////////////////////////////
3683 /// Stream an object of class TGeoManager.
3684 
3685 void TGeoManager::Streamer(TBuffer &R__b)
3686 {
3687  if (R__b.IsReading()) {
3688  R__b.ReadClassBuffer(TGeoManager::Class(), this);
3690  CloseGeometry();
3693  } else {
3694  R__b.WriteClassBuffer(TGeoManager::Class(), this);
3695  }
3696 }
3697 
3698 ////////////////////////////////////////////////////////////////////////////////
3699 /// Execute mouse actions on this manager.
3700 
3701 void TGeoManager::ExecuteEvent(Int_t event, Int_t px, Int_t py)
3703  if (!fPainter) return;
3704  fPainter->ExecuteManagerEvent(this, event, px, py);
3705 }
3706 
3707 ////////////////////////////////////////////////////////////////////////////////
3708 /// Export this geometry to a file
3709 ///
3710 /// - Case 1: root file or root/xml file
3711 /// if filename end with ".root". The key will be named name
3712 /// By default the geometry is saved without the voxelisation info.
3713 /// Use option 'v" to save the voxelisation info.
3714 /// if filename end with ".xml" a root/xml file is produced.
3715 ///
3716 /// - Case 2: C++ script
3717 /// if filename end with ".C"
3718 ///
3719 /// - Case 3: gdml file
3720 /// if filename end with ".gdml"
3721 /// NOTE that to use this option, the PYTHONPATH must be defined like
3722 /// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/geom/gdml
3723 ///
3724 
3725 Int_t TGeoManager::Export(const char *filename, const char *name, Option_t *option)
3727  TString sfile(filename);
3728  if (sfile.Contains(".C")) {
3729  //Save geometry as a C++ script
3730  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as C++ code", GetName(), GetTitle());
3731  fTopVolume->SaveAs(filename);
3732  return 1;
3733  }
3734  if (sfile.Contains(".gdml")) {
3735  //Save geometry as a gdml file
3736  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as gdml code", GetName(), GetTitle());
3737  //C++ version
3738  TString cmd ;
3739  cmd = TString::Format("TGDMLWrite::StartGDMLWriting(gGeoManager,\"%s\",\"%s\")", filename, option);
3740  gROOT->ProcessLineFast(cmd);
3741  return 1;
3742  }
3743  if (sfile.Contains(".root") || sfile.Contains(".xml")) {
3744  //Save geometry as a root file
3745  TFile *f = TFile::Open(filename,"recreate");
3746  if (!f || f->IsZombie()) {
3747  Error("Export","Cannot open file");
3748  return 0;
3749  }
3750  TString keyname = name;
3751  if (keyname.IsNull()) keyname = GetName();
3752  TString opt = option;
3753  opt.ToLower();
3754  if (opt.Contains("v")) {
3755  fStreamVoxels = kTRUE;
3756  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as root file. Optimizations streamed.", GetName(), GetTitle());
3757  } else {
3759  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as root file. Optimizations not streamed.", GetName(), GetTitle());
3760  }
3761  Int_t nbytes = Write(keyname);
3763  delete f;
3764  return nbytes;
3765  }
3766  return 0;
3767 }
3768 
3769 ////////////////////////////////////////////////////////////////////////////////
3770 /// Lock current geometry so that no other geometry can be imported.
3771 
3774  fgLock = kTRUE;
3775 }
3776 
3777 ////////////////////////////////////////////////////////////////////////////////
3778 /// Unlock current geometry.
3779 
3782  fgLock = kFALSE;
3783 }
3784 
3785 ////////////////////////////////////////////////////////////////////////////////
3786 /// Check lock state.
3787 
3790  return fgLock;
3791 }
3792 
3793 ////////////////////////////////////////////////////////////////////////////////
3794 /// Set verbosity level (static function).
3795 /// - 0 - suppress messages related to geom-painter visibility level
3796 /// - 1 - default value
3797 
3800  return fgVerboseLevel;
3801 }
3802 
3803 ////////////////////////////////////////////////////////////////////////////////
3804 /// Return current verbosity level (static function).
3805 
3808  fgVerboseLevel = vl;
3809 }
3810 
3811 ////////////////////////////////////////////////////////////////////////////////
3812 ///static function
3813 ///Import a geometry from a gdml or ROOT file
3814 ///
3815 /// - Case 1: gdml
3816 /// if filename ends with ".gdml" the foreign geometry described with gdml
3817 /// is imported executing some python scripts in $ROOTSYS/gdml.
3818 /// NOTE that to use this option, the PYTHONPATH must be defined like
3819 /// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
3820 ///
3821 /// - Case 2: root file (.root) or root/xml file (.xml)
3822 /// Import in memory from filename the geometry with key=name.
3823 /// if name="" (default), the first TGeoManager object in the file is returned.
3824 ///
3825 /// Note that this function deletes the current gGeoManager (if one)
3826 /// before importing the new object.
3827 
3828 TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
3830  if (fgLock) {
3831  ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
3832  return NULL;
3833  }
3834  if (!filename) return 0;
3835  if (fgVerboseLevel>0) ::Info("TGeoManager::Import","Reading geometry from file: %s",filename);
3836 
3837  if (gGeoManager) delete gGeoManager;
3838  gGeoManager = 0;
3839 
3840  if (strstr(filename,".gdml")) {
3841  // import from a gdml file
3842  new TGeoManager("GDMLImport", "Geometry imported from GDML");
3843  TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
3844  TGeoVolume* world = (TGeoVolume*)gROOT->ProcessLineFast(cmd);
3845 
3846  if(world == 0) {
3847  ::Error("TGeoManager::Import", "Cannot open file");
3848  }
3849  else {
3850  gGeoManager->SetTopVolume(world);
3851  gGeoManager->CloseGeometry();
3852  gGeoManager->DefaultColors();
3853  }
3854  } else {
3855  // import from a root file
3856  TDirectory::TContext ctxt;
3857  // in case a web file is specified, use the cacheread option to cache
3858  // this file in the cache directory
3859  TFile *f = 0;
3860  if (strstr(filename,"http")) f = TFile::Open(filename,"CACHEREAD");
3861  else f = TFile::Open(filename);
3862  if (!f || f->IsZombie()) {
3863  ::Error("TGeoManager::Import", "Cannot open file");
3864  return 0;
3865  }
3866  if (name && strlen(name) > 0) {
3867  gGeoManager = (TGeoManager*)f->Get(name);
3868  } else {
3869  TIter next(f->GetListOfKeys());
3870  TKey *key;
3871  while ((key = (TKey*)next())) {
3872  if (strcmp(key->GetClassName(),"TGeoManager") != 0) continue;
3873  gGeoManager = (TGeoManager*)key->ReadObj();
3874  break;
3875  }
3876  }
3877  delete f;
3878  }
3879  if (!gGeoManager) return 0;
3880  if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager)) gROOT->GetListOfGeometries()->Add(gGeoManager);
3881  if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager)) gROOT->GetListOfBrowsables()->Add(gGeoManager);
3882  gGeoManager->UpdateElements();
3883  return gGeoManager;
3884 }
3885 
3886 ////////////////////////////////////////////////////////////////////////////////
3887 /// Update element flags when geometry is loaded from a file.
3888 
3891  if (!fElementTable) return;
3892  TIter next(fMaterials);
3893  TGeoMaterial *mat;
3894  TGeoMixture *mix;
3895  TGeoElement *elem, *elem_table;
3896  Int_t i, nelem;
3897  while ((mat=(TGeoMaterial*)next())) {
3898  if (mat->IsMixture()) {
3899  mix = (TGeoMixture*)mat;
3900  nelem = mix->GetNelements();
3901  for (i=0; i<nelem; i++) {
3902  elem = mix->GetElement(i);
3903  if (!elem) continue;
3904  elem_table = fElementTable->GetElement(elem->Z());
3905  if (!elem_table) continue;
3906  if (elem != elem_table) {
3907  elem_table->SetDefined(elem->IsDefined());
3908  elem_table->SetUsed(elem->IsUsed());
3909  } else {
3910  elem_table->SetDefined();
3911  }
3912  }
3913  } else {
3914  elem = mat->GetElement();
3915  if (!elem) continue;
3916  elem_table = fElementTable->GetElement(elem->Z());
3917  if (!elem_table) continue;
3918  if (elem != elem_table) {
3919  elem_table->SetDefined(elem->IsDefined());
3920  elem_table->SetUsed(elem->IsUsed());
3921  } else {
3922  elem_table->SetUsed();
3923  }
3924  }
3925  }
3926 }
3927 
3928 ////////////////////////////////////////////////////////////////////////////////
3929 /// Initialize PNE array for fast access via index and unique-id.
3930 
3933  if (fHashPNE) {
3934  fArrayPNE = new TObjArray(fHashPNE->GetSize());
3935  TIter next(fHashPNE);
3936  TObject *obj;
3937  while ((obj = next())) {
3938  fArrayPNE->Add(obj);
3939  }
3940  return kTRUE;
3941  }
3942  return kFALSE;
3943 }
3944 
3945 ////////////////////////////////////////////////////////////////////////////////
3946 /// Get time cut for drawing tracks.
3947 
3950  tmin = fTmin;
3951  tmax = fTmax;
3952  return fTimeCut;
3953 }
3954 
3955 ////////////////////////////////////////////////////////////////////////////////
3956 /// Set time cut interval for drawing tracks. If called with no arguments, time
3957 /// cut will be disabled.
3958 
3961  fTmin = tmin;
3962  fTmax = tmax;
3963  if (tmin==0 && tmax==999) fTimeCut = kFALSE;
3964  else fTimeCut = kTRUE;
3965  if (fTracks && !IsAnimatingTracks()) ModifiedPad();
3966 }
3967 
3968 ////////////////////////////////////////////////////////////////////////////////
3969 /// Convert coordinates from master volume frame to top.
3970 
3971 void TGeoManager::MasterToTop(const Double_t *master, Double_t *top) const
3973  GetCurrentNavigator()->MasterToLocal(master, top);
3974 }
3975 
3976 ////////////////////////////////////////////////////////////////////////////////
3977 /// Convert coordinates from top volume frame to master.
3978 
3979 void TGeoManager::TopToMaster(const Double_t *top, Double_t *master) const
3981  GetCurrentNavigator()->LocalToMaster(top, master);
3982 }
3983 
3984 ////////////////////////////////////////////////////////////////////////////////
3985 /// Create a parallel world for prioritised navigation. This can be populated
3986 /// with physical nodes and can be navigated independently using its API.
3987 /// In case the flag SetUseParallelWorldNav is set, any navigation query in the
3988 /// main geometry is checked against the parallel geometry, which gets priority
3989 /// in case of overlaps with the main geometry volumes.
3990 
3993  fParallelWorld = new TGeoParallelWorld(name, this);
3994  return fParallelWorld;
3995 }
3996 
3997 ////////////////////////////////////////////////////////////////////////////////
3998 /// Activate/deactivate usage of parallel world navigation. Can only be done if
3999 /// there is a parallel world. Activating navigation will automatically close
4000 /// the parallel geometry.
4001 
4004  if (!fParallelWorld) {
4005  Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
4006  return;
4007  }
4008  if (!flag) {
4009  fUsePWNav = flag;
4010  return;
4011  }
4012  if (!fClosed) {
4013  Error("SetUseParallelWorldNav", "The geometry must be closed first");
4014  return;
4015  }
4016  // Closing the parallel world geometry is mandatory
4018 }
void SetTopVisible(Bool_t vis=kTRUE)
make top volume visible on screen
void SetPhysicalNode(TGeoPhysicalNode *node)
Setter for the corresponding physical node.
TObjArray * fShapes
Definition: TGeoManager.h:84
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:261
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="")
Classify a given point. See TGeoChecker::CheckPoint().
void ClearThreadData() const
Double_t fPhimin
Definition: TGeoManager.h:52
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:785
virtual Int_t GetVisLevel() const =0
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
Int_t AddShape(TGeoShape *shape)
Add a shape to the list. Returns index of the shape in list.
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 IsReading() const
Definition: TBuffer.h:83
Volume families.
Definition: TGeoVolume.h:256
TList * fMedia
Definition: TGeoManager.h:93
A node containing local transformation.
Definition: TGeoNode.h:149
void CheckGeometryFull(Int_t ntracks=1000000, Double_t vx=0., Double_t vy=0., Double_t vz=0., Option_t *option="ob")
Geometry checking.
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 ModifiedPad() const
Send "Modified" signal to painter.
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
Mixtures of elements.
Definition: TGeoMaterial.h:134
void PrintOverlaps() const
Prints the current list of overlaps.
TObjArray * fVolumes
Definition: TGeoManager.h:85
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
An array of TObjects.
Definition: TObjArray.h:37
virtual Int_t CountVisibleNodes()=0
TGeoHMatrix * fGLMatrix
Definition: TGeoManager.h:113
TGeoPhysicalNode * MakePhysicalNode(const char *path=0)
Makes a physical node corresponding to a path.
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
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.
virtual void GetViewAngles(Double_t &, Double_t &, Double_t &)
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
void AddLast(TObject *obj)
Add object at the end of the list.
Definition: THashList.cxx:95
Bool_t GetTminTmax(Double_t &tmin, Double_t &tmax) const
Get time cut for drawing tracks.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
void CheckGeometry(Option_t *option="")
Perform last checks on the geometry.
Int_t GetCurrentNodeId() const
Get the unique ID of the current node.
void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)
Test for shape navigation methods.
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.
The manager class for any TGeo geometry.
Definition: TGeoManager.h:38
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
Make an assembly of volumes.
virtual void CreateThreadData(Int_t nthreads)
Definition: TGeoVolume.cxx:431
Box class.
Definition: TGeoBBox.h:17
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.
Bool_t fActivity
flag for GL reflections
Definition: TGeoManager.h:79
virtual void EditGeometry(Option_t *option="")=0
void Release()
Definition: TGeoVolume.h:143
void ClearAttributes()
Reset all attributes to default ones.
Volume assemblies.
Definition: TGeoVolume.h:307
void Voxelize(Option_t *option)
build the voxels for this volume
Table of elements.
Definition: TGeoElement.h:369
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.
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 SetFinder(TGeoPatternFinder *finder)
Definition: TGeoVolume.h:234
virtual void ModifiedPad(Bool_t update=kFALSE) const =0
void SetAllIndex()
Assigns uid&#39;s for all materials,media and matrices.
Bool_t fMatrixTransform
flag that the list of physical nodes has to be drawn
Definition: TGeoManager.h:77
virtual void Sort(Int_t upto=kMaxInt)
If objects in array are sortable (i.e.
Definition: TObjArray.cxx:802
virtual Double_t * GetViewBox()=0
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
virtual void Clear(Option_t *option="")
Remove all objects from the array.
Definition: TObjArray.cxx:320
float Float_t
Definition: RtypesCore.h:53
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.
virtual Double_t GetDensity() const
Definition: TGeoMaterial.h:87
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 BombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new &#39;bombed&#39; translation vector according current exploded view mode.
Bool_t IsOverlapping() const
Definition: TGeoNode.h:102
virtual TVirtualGeoTrack * AddTrack(Int_t id, Int_t pdgcode, TObject *particle)=0
const char Option_t
Definition: RtypesCore.h:62
Geometrical transformation package.
Definition: TGeoMatrix.h:40
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:355
Definition: Rtypes.h:59
Int_t ReplaceVolume(TGeoVolume *vorig, TGeoVolume *vnew)
Replaces all occurrences of VORIG with VNEW in the geometry tree.
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 * 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.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=0)
Returns the deepest node containing fPoint, which must be set a priori.
static TGeoMedium * DummyMedium()
Definition: TGeoVolume.cxx:439
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
void Test(Int_t npoints=1000000, Option_t *option="")
Check time of finding "Where am I" for n points.
Int_t Z() const
Definition: TGeoElement.h:73
void CdUp()
Go one level up in geometry.
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:638
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check all geometry for illegal overlaps within a limit OVLP.
void SetRTmode(Int_t mode)
Change raytracing mode.
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
std::map< std::thread::id, Int_t > ThreadsMap_t
Definition: TGeoManager.h:101
virtual void Test(Int_t npoints, Option_t *option)=0
THashList * fHashVolumes
Definition: TGeoManager.h:122
TGeoMaterial * GetMaterial() const
Definition: TGeoMedium.h:52
TVirtualGeoTrack * GetTrack(Int_t index)
Definition: TGeoManager.h:375
void Init()
Initialize manager class.
#define BIT(n)
Definition: Rtypes.h:78
TH1 * h
Definition: legend2.C:5
Int_t GetTrackIndex(Int_t id) const
Get index for track id, -1 if not found.
static Int_t fgMaxDaughters
Maximum level in geometry.
Definition: TGeoManager.h:45
void GetBranchOnlys(Int_t *isonly) const
Fill node copy numbers of current branch into an array.
An identity transformation.
Definition: TGeoMatrix.h:383
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
TGeoElementTable * GetElementTable()
Returns material table. Creates it if not existing.
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
virtual void CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)=0
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
virtual Double_t Weight(Double_t precision, Option_t *option="v")=0
void SetVisBranch()
Set branch type visibility.
Definition: TGeoAtt.cxx:67
Definition: Rtypes.h:58
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
Bool_t fMatrixReflection
flag for using GL matrix
Definition: TGeoManager.h:78
virtual TGeoElement * GetElement(Int_t i=0) const
Retrieve the pointer to the element corresponding to component I.
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
TVirtualGeoTrack * fCurrentTrack
Definition: TGeoManager.h:66
Int_t fNtracks
Definition: TGeoManager.h:64
void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: THashList.cxx:207
Int_t fNNodes
upper time limit for tracks drawing
Definition: TGeoManager.h:56
static Int_t GetVerboseLevel()
Set verbosity level (static function).
static void SetVerboseLevel(Int_t vl)
Return current verbosity level (static function).
#define gROOT
Definition: TROOT.h:402
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.
Int_t fPdgId[1024]
Definition: TGeoManager.h:68
virtual TObject * Remove(TObject *obj)
Remove object from array.
Definition: TObjArray.cxx:703
Int_t AddRegion(TGeoRegion *region)
Add a new region of volumes.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
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.
virtual void PrintOverlaps() const =0
Int_t GetId() const
Definition: TGeoMedium.h:48
Int_t LoadPlugin()
Load the plugin library for this handler.
void ResetUserData()
Sets all pointers TGeoVolume::fField to NULL.
TGeoVolume * Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar=0)
Create a volume in GEANT3 style.
void ViewLeaves(Bool_t flag=kTRUE)
Set visualization option (leaves only OR all volumes)
void InspectState() const
Inspects path and all flags for the current state.
Basic string class.
Definition: TString.h:125
Matrix class used for computing global transformations Should NOT be used for node definition...
Definition: TGeoMatrix.h:420
Base class describing materials.
Definition: TGeoMaterial.h:29
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
static void ClearThreadsMap()
Clear the current map of threads.
void GetBranchNames(Int_t *names) const
Fill volume names of current branch into an array.
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
TObjArray * fUniqueVolumes
Definition: TGeoManager.h:114
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGeoNodeCache * GetCache() const
TGeoNode * fTopNode
top level volume in geometry
Definition: TGeoManager.h:111
Bool_t fIsNodeSelectable
switch ON/OFF volume activity (default OFF - all volumes active))
Definition: TGeoManager.h:80
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
void OptimizeVoxels(const char *filename="tgeovox.C")
Optimize voxelization type for all volumes. Save best choice in a macro.
static Int_t Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
Parse a string boolean expression and do a syntax check.
Int_t fVisOption
Definition: TGeoManager.h:61
TVirtualGeoTrack * MakeTrack(Int_t id, Int_t pdgcode, TObject *particle)
Makes a primary track but do not attach it to the list of tracks.
Definition: Rtypes.h:59
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.
Definition: Rtypes.h:59
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 * 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.
Int_t GetNvert() const
Definition: TGeoXtru.h:94
virtual void ExecuteManagerEvent(TGeoManager *geom, Int_t event, Int_t px, Int_t py)=0
TGeoShape * fClippingShape
Definition: TGeoManager.h:115
virtual void RandomPoints(const TGeoVolume *vol, Int_t npoints, Option_t *option="")=0
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
Bool_t fDrawExtra
Definition: TGeoManager.h:76
TObjArray * fPdgNames
Definition: TGeoManager.h:90
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
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.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
void AnimateTracks(Double_t tmin=0, Double_t tmax=5E-8, Int_t nframes=200, Option_t *option="/*")
Draw animation of tracks.
void Refresh()
Refresh this physical node.
Int_t GetId() const
virtual void DefaultAngles()=0
TGeoVoxelFinder * GetVoxels() const
Getter for optimization structure.
Int_t GetVisLevel() const
Returns current depth to which geometry is drawn.
Bool_t InitArrayPNE() const
Initialize PNE array for fast access via index and unique-id.
static void SetNavigatorsLock(Bool_t flag)
Set the lock for navigators.
Int_t GetRefCount() const
Definition: TGeoVolume.h:137
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.
const char * GetPdgName(Int_t pdg) const
Get name for given pdg code;.
Int_t GetSafeLevel() const
Go upwards the tree until a non-overlapping node.
TGeoVolume * GetMotherVolume() const
Definition: TGeoNode.h:89
void GetBranchOnlys(Int_t *isonly) const
Fill node copy numbers of current branch into an array.
TObjArray * fArrayPNE
Definition: TGeoManager.h:125
TObjArray * fGShapes
Definition: TGeoManager.h:87
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual Int_t GetByteCount() const
get the total size in bytes for this volume
void SetVisibility(TObject *obj, Bool_t vis)
Set visibility for a volume.
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.
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
void SetVisDensity(Double_t dens=0.01)
Set density threshold.
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
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.
static Int_t GetNumThreads()
Returns number of threads that were set to use geometry.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3950
Int_t CountNodes(Int_t nlevels=1000, Int_t option=0)
Count total number of subnodes starting from this volume, nlevels down.
Definition: TGeoVolume.cxx:754
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:105
TObjArray * fOverlaps
Definition: TGeoManager.h:95
Int_t fNsegments
Definition: TGeoManager.h:63
virtual void SetClippingShape(TGeoShape *shape)=0
void InspectState() const
Inspects path and all flags for the current state.
Bool_t fIsGeomCleaning
flag set when reading geometry
Definition: TGeoManager.h:73
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
TObjArray * fMatrices
current painter
Definition: TGeoManager.h:83
void ResetState()
Reset current state flags.
Int_t GetNdaughters() const
Definition: TGeoVolume.h:350
TGeoMaterial * GetMaterial(const char *matname) const
Search for a named material. All trailing blanks stripped.
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
TGeoParallelWorld * fParallelWorld
Definition: TGeoManager.h:134
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.
#define SafeDelete(p)
Definition: RConfig.h:509
virtual Int_t Export(const char *filename, const char *name="", Option_t *option="vg")
Export this geometry to a file.
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.
Sequenceable collection abstract base class.
Double_t x[n]
Definition: legend1.C:17
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 UpdateElements()
Update element flags when geometry is loaded from a file.
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...
static Bool_t fgLock
mutex for navigator booking in MT mode
Definition: TGeoManager.h:42
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:2365
void SetVolumeAttribute(const char *name, const char *att, Int_t val)
Set volume attributes in G3 style.
void RandomRays(Int_t nrays=1000, Double_t startx=0, Double_t starty=0, Double_t startz=0, const char *target_vol=0, Bool_t check_norm=kFALSE)
Randomly shoot nrays and plot intersections with surfaces for current top node.
virtual void GrabFocus(Int_t nfr=0, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0)=0
Int_t GetLevel() const
Definition: TGeoNode.h:274
void Class()
Definition: Class.C:29
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
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.
Int_t AddTrack(Int_t id, Int_t pdgcode, TObject *particle=0)
Add a track to the list of tracks.
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
A geometry iterator.
Definition: TGeoNode.h:243
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Definition: TObjArray.cxx:414
virtual void SetNsegments(Int_t nseg=20)=0
void CdDown(Int_t index)
Make a daughter of current node current.
void SetVisStreamed(Bool_t vis=kTRUE)
Mark attributes as "streamed to file".
Definition: TGeoAtt.cxx:123
void CleanGarbage()
Clean temporary volumes and shapes from garbage collection.
THashList * fHashGVolumes
hash list of volumes providing fast search
Definition: TGeoManager.h:123
void ClearShape(const TGeoShape *shape)
Remove a shape from the list of shapes.
Double_t fTmax
lower time limit for tracks drawing
Definition: TGeoManager.h:55
static Bool_t IsLocked()
Check lock state.
THashList * fHashPNE
hash list of group volumes providing fast search
Definition: TGeoManager.h:124
void Browse(TBrowser *b)
Describe how to browse this object.
Bool_t IsUsed() const
Definition: TGeoElement.h:88
void SortOverlaps()
Sort overlaps by decreasing overlap distance. Extrusions comes first.
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=0)
Make an TGeoArb8 volume.
virtual void SetExplodedView(Int_t iopt=0)=0
virtual void BombTranslation(const Double_t *tr, Double_t *bombtr)=0
Base class for chemical elements.
Definition: TGeoElement.h:36
Bool_t IsDefined() const
Definition: TGeoElement.h:86
void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
Retrieve cartesian and radial bomb factors.
TGeoVolume * MakeReflectedVolume(const char *newname="") const
Make a copy of this volume which is reflected with respect to XY plane.
TGeoNavigator * fCurrentNavigator
Lock existing navigators.
Definition: TGeoManager.h:108
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
TGeoVolume * GetCurrentVolume() const
TGeoNavigator * GetCurrentNavigator() const
TGeoMedium * GetMedium() const
Definition: TGeoVolume.h:176
static Int_t GetMaxDaughters()
Return maximum number of daughters of a volume used in the geometry.
void TopToMaster(const Double_t *top, Double_t *master) const
Convert coordinates from top volume frame to master.
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...
Int_t AddVolume(TGeoVolume *volume)
Add a volume to the list. Returns index of the volume in list.
virtual Bool_t IsVisible() const
Definition: TGeoVolume.h:156
Bool_t CheckPath(const char *path) const
Check if a geometry path is valid without changing the state of the navigator.
TGeoVolume * fTopVolume
current volume
Definition: TGeoManager.h:110
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
void LocalToMaster(const Double_t *local, Double_t *master) const
Definition: TGeoManager.h:511
TVirtualGeoTrack * GetParentTrackOfId(Int_t id) const
Get parent track with a given ID.
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.
Int_t fNPNEId
Definition: TGeoManager.h:127
virtual TGeoMatrix * GetMatrix() const =0
static Int_t fgNumThreads
Thread id&#39;s map.
Definition: TGeoManager.h:106
Bool_t InsertPNEId(Int_t uid, Int_t ientry)
Insert a PN entry in the sorted array of indexes.
ThreadsMap_t::const_iterator ThreadsMapIt_t
Definition: TGeoManager.h:102
virtual TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Recursively search through this track for a daughter particle (at any depth) with the specified id...
virtual void CheckBoundaryReference(Int_t icheck=-1)=0
Bool_t IsRunTime() const
Definition: TGeoVolume.h:117
Int_t GetVisOption() const
Returns current depth to which geometry is drawn.
Base class for user-defined tracks attached to a geometry.
Double_t ATan2(Double_t, Double_t)
Definition: TMath.h:580
void SetClippingShape(TGeoShape *clip)
Set a user-defined shape as clipping for ray tracing.
TGeoMaterial * FindDuplicateMaterial(const TGeoMaterial *mat) const
Find if a given material duplicates an existing one.
TGeoVolume * MakeArb8(const char *name, TGeoMedium *medium, Double_t dz, Double_t *vertices=0)
Make an TGeoArb8 volume.
void SetMaxVisNodes(Int_t maxnodes=10000)
set the maximum number of visible nodes.
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual void SetBombFactors(Double_t bombx=1.3, Double_t bomby=1.3, Double_t bombz=1.3, Double_t bombr=1.3)=0
XFontStruct * id
Definition: TGX11.cxx:108
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.
void RestoreMasterVolume()
Restore the master volume of the geometry.
Bool_t fPhiCut
flag to notify that the manager is being destructed
Definition: TGeoManager.h:74
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition: TClass.cxx:5632
TH1F * h1
Definition: legend1.C:5
NavigatorsMap_t fNavigators
Definition: TGeoManager.h:104
TGeoNavigatorArray * GetListOfNavigators() const
Get list of navigators for the calling thread.
Bool_t fIsGeomReading
Definition: TGeoManager.h:72
Int_t fVisLevel
Definition: TGeoManager.h:62
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.
virtual void DrawCurrentPoint(Int_t color)=0
void ResetState()
Reset current state flags.
Int_t GetNAlignable(Bool_t with_uid=kFALSE) const
Retrieves number of PN entries with or without UID.
Int_t TransformVolumeToAssembly(const char *vname)
Transform all volumes named VNAME to assemblies. The volumes must be virtual.
TGeoNode * GetCurrentNode() const
Definition: TGeoManager.h:487
Bool_t IsAnimatingTracks() const
Definition: TGeoManager.h:387
static Int_t fgVerboseLevel
Lock preventing a second geometry to be loaded.
Definition: TGeoManager.h:43
The knowledge of the path to the objects that need to be misaligned is essential since there is no ot...
static TGeoVolumeAssembly * MakeAssemblyFromVolume(TGeoVolume *vol)
Make a clone of volume VOL but which is an assembly.
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition: TObject.h:134
void RefreshPhysicalNodes(Bool_t lock=kTRUE)
Refresh physical nodes to reflect the actual geometry paths after alignment was applied.
virtual void ClearThreadData() const
Definition: TGeoVolume.cxx:423
virtual Double_t GetZ() const
Definition: TGeoMaterial.h:85
Int_t fMaxThreads
Definition: TGeoManager.h:130
Int_t * fKeyPNEId
Definition: TGeoManager.h:128
REAL * vertex
Definition: triangle.c:512
void SortNodes()
sort nodes by decreasing volume of the bounding box.
Bool_t fLoopVolumes
flag that geometry is closed
Definition: TGeoManager.h:70
Physical nodes are the actual &#39;touchable&#39; objects in the geometry, representing a path of positioned ...
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition: TObject.cxx:705
TGeoPhysicalNode * MakeAlignablePN(const char *name)
Make a physical node from the path pointed by an alignable object with a given name.
TGeoNode * SearchNode(Bool_t downwards=kFALSE, const TGeoNode *skipnode=0)
Returns the deepest node containing fPoint, which must be set a priori.
void CdTop()
Make top level node the current node.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
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.
Class handling Boolean composition of shapes.
virtual TGeoNode * SamplePoints(Int_t npoints, Double_t &dist, Double_t epsil, const char *g3path)=0
virtual void SetTopVisible(Bool_t vis=kTRUE)=0
void GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
Fill node copy numbers of current branch into an array.
void SelectTrackingMedia()
Define different tracking media.
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
Int_t GetUID(const char *volname) const
Retrieve unique id for a volume name. Return -1 if name not found.
Int_t AddOverlap(const TNamed *ovlp)
Add an illegal overlap/extrusion to the list.
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
Make an assembly of volumes.
Double_t fTmin
highest range for phi cut
Definition: TGeoManager.h:54
void RemoveNavigator(const TGeoNavigator *nav)
Clear a single navigator.
TObjArray * fPhysicalNodes
Definition: TGeoManager.h:86
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
Bool_t fTimeCut
Definition: TGeoManager.h:75
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:867
TGeoPNEntry * GetAlignableEntryByUID(Int_t uid) const
Retrieves an existing alignable object having a preset UID.
Int_t CountNodes(const TGeoVolume *vol=0, Int_t nlevels=10000, Int_t option=0)
Count the total number of nodes starting from a volume, nlevels down.
Int_t * fNodeIdArray
table of elements
Definition: TGeoManager.h:118
Int_t fNLevel
array of node id&#39;s
Definition: TGeoManager.h:119
void SetNeedRebuild(Bool_t flag=kTRUE)
void Clear(Option_t *option="")
Remove all objects from the list.
Definition: THashList.cxx:189
Int_t GetNsegments() const
Get number of segments approximating circles.
virtual void AfterStreamer()
Definition: TGeoShape.h:94
Bool_t cd(const char *path="")
Browse the tree of nodes starting from top node according to pathname.
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition: TNamed.cxx:51
Double_t Safety(Bool_t inside=kFALSE)
Compute safe distance from the current point.
void LocalToMaster(const Double_t *local, Double_t *master) const
Base abstract class for all shapes.
Definition: TGeoShape.h:25
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition: TGeoNode.cxx:214
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Definition: TObjArray.cxx:234
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 &#39;mat<index>&#39;.
Int_t AddMaterial(TGeoMaterial *material)
Add a material to the list. Returns index of the material in list.
void SetMotherVolume(TGeoVolume *mother)
Definition: TGeoNode.h:120
ROOT::R::TRInterface & r
Definition: Object.C:4
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.
static void LockGeometry()
Lock current geometry so that no other geometry can be imported.
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.
Class describing rotation + translation.
Definition: TGeoMatrix.h:291
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)...
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
void SaveAttributes(std::ostream &out)
save attributes for this node
Definition: TGeoNode.cxx:439
void SetField(TObject *field)
Definition: TGeoVolume.h:221
Int_t GetVirtualLevel()
Find level of virtuality of current overlapping node (number of levels up having the same tracking me...
auto * a
Definition: textangle.C:12
virtual void CheckGeometryFull(Bool_t checkoverlaps=kTRUE, Bool_t checkcrossings=kTRUE, Int_t nrays=10000, const Double_t *vertex=NULL)=0
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 ...
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
void DefaultColors()
Set default volume colors according to A of material.
TVirtualGeoTrack * GetMother() const
Int_t fExplodedView
Definition: TGeoManager.h:60
TGeoNavigator * AddNavigator()
Add a navigator in the list of navigators.
Long_t ExecPlugin(int nargs, const T &... params)
Bool_t IsInPhiRange() const
True if current node is in phi range.
TGeoManager()
Default constructor.
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
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.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:818
virtual Bool_t IsComposite() const
Definition: TGeoShape.h:130
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 void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const =0
static Int_t fgMaxLevel
Verbosity level for Info messages (no IO).
Definition: TGeoManager.h:44
void SetTransparency(Char_t transparency=0)
Definition: TGeoVolume.h:220
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
virtual Int_t GetNelements() const
Definition: TGeoMaterial.h:172
TVirtualGeoTrack * GetTrackOfId(Int_t id) const
Get track with a given ID.
Double_t fPhimax
lowest range for phi cut
Definition: TGeoManager.h:53
Regions are groups of volumes having a common set of user tracking cuts.
Definition: TGeoRegion.h:36
TGeoVolumeMulti * MakeVolumeMulti(const char *name, TGeoMedium *medium)
Make a TGeoVolumeMulti handling a list of volumes.
void SetPdgName(Int_t pdg, const char *name)
Set a name for a particle having a given pdg.
void SetMatrix(const TGeoMatrix *matrix)
Matrix setter.
Definition: TGeoNode.cxx:816
Bool_t IsMultiThread() const
Definition: TGeoManager.h:439
void RefreshPhysicalNodes()
Refresh the node pointers and re-voxelize.
Int_t fMaxVisNodes
Definition: TGeoManager.h:65
Int_t GetEntriesFast() const
Definition: TObjArray.h:64
void UnmarkSaved()
Reset SavePrimitive bits.
virtual void EstimateCameraMove(Double_t, Double_t, Double_t *, Double_t *)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
void DrawCurrentPoint(Int_t color=2)
Draw current point in the same view.
void CdDown(Int_t index)
Make a daughter of current node current.
Ssiz_t Length() const
Definition: TString.h:386
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Definition: TGeoMatrix.cxx:526
virtual void SetCheckedNode(TGeoNode *node)=0
Int_t fNpdg
current track
Definition: TGeoManager.h:67
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1080
Bool_t CheckPath(const char *path) const
Check if a geometry path is valid without changing the state of the current navigator.
TObjArray * fTracks
list of runtime volumes
Definition: TGeoManager.h:89
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.
Double_t fVisDensity
particles to be drawn
Definition: TGeoManager.h:59
virtual Int_t GetByteCount(Option_t *option=0)
Get total size of geometry in bytes.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:354
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 CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TList * fMaterials
Definition: TGeoManager.h:92
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.
virtual Int_t GetByteCount() const
Get total size in bytes of this.
Definition: TGeoMatrix.cxx:282
Int_t * fValuePNEId
Definition: TGeoManager.h:129
void DrawTracks(Option_t *option="")
Draw tracks over the geometry, according to option.
void SetCheckedNode(TGeoNode *node)
Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
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.
Bool_t fStreamVoxels
flag volume lists loop
Definition: TGeoManager.h:71
TVirtualGeoTrack * FindTrackWithId(Int_t id) const
Search the track hierarchy to find the track with the given id.
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)
void SetUseParallelWorldNav(Bool_t flag)
Activate/deactivate usage of parallel world navigation.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
Definition: TObjArray.cxx:253
void DrawPath(const char *path, Option_t *option="")
Draw current path.
virtual ~TGeoManager()
Destructor.
TObjArray * fNodes
Definition: TGeoManager.h:94
constexpr Double_t E()
Definition: TMath.h:74
void RandomPoints(const TGeoVolume *vol, Int_t npoints=10000, Option_t *option="")
Draw random points in the bounding box of a volume.
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.
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
TObjArray * fGVolumes
list of runtime shapes
Definition: TGeoManager.h:88
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.
const Bool_t kFALSE
Definition: RtypesCore.h:88
TGeoMedium * GetMedium(const char *medium) const
Search for a named tracking medium. All trailing blanks stripped.
virtual TGeoElement * GetElement(Int_t i=0) const
Get a pointer to the element this material is made of.
void SetOverlapping(Bool_t flag=kTRUE)
Definition: TGeoNode.h:115
TGeoVolume * fCurrentVolume
current navigator
Definition: TGeoManager.h:109
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.
Int_t fRaytraceMode
Flag for multi-threading.
Definition: TGeoManager.h:132
void DefaultAngles()
Set default angles for a given view.
Bool_t IsClosed() const
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Bool_t cd(const char *path="")
Browse the tree of nodes starting from fTopNode according to pathname.
void TestOverlaps(const char *path="")
Geometry overlap checker based on sampling.
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.
static std::mutex fgMutex
Definition: TGeoManager.h:41
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.
An extrusion with fixed outline shape in x-y and a sequence of z extents (segments).
Definition: TGeoXtru.h:21
static Int_t GetMaxLevels()
Return maximum number of levels used in the geometry.
virtual void SetVisOption(Int_t option=0)=0
TObject * UncheckedAt(Int_t i) const
Definition: TObjArray.h:89
void SetUsed(Bool_t flag=kTRUE)
Definition: TGeoElement.h:91
virtual void ReflectZ(Bool_t leftside, Bool_t rotonly=kFALSE)
Multiply by a reflection respect to XY.
Definition: TGeoMatrix.cxx:519
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.
#define ClassImp(name)
Definition: Rtypes.h:359
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.
Definition: TROOT.cxx:528
void DoBackupState()
Backup the current state without affecting the cache stack.
virtual Bool_t IsMixture() const
Definition: TGeoMaterial.h:108
void CdUp()
Go one level up in geometry.
void RemoveMaterial(Int_t index)
Remove material at given index.
TGeoNavigator * SetCurrentNavigator(Int_t inav)
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlapping node.
double Double_t
Definition: RtypesCore.h:55
Int_t GetNumber() const
Definition: TGeoVolume.h:185
virtual void SetVisibility(Bool_t vis=kTRUE)
set visibility of this volume
void RegisterMatrix(TGeoMatrix *matrix)
Register a matrix to the list of matrices.
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
void SaveAs(const char *filename, Option_t *option="") const
Save geometry having this as top volume as a C++ macro.
TVirtualGeoPainter * fPainter
flag that nodes are the selected objects in pad rather than volumes
Definition: TGeoManager.h:81
void Voxelize(Option_t *option=0)
Voxelize all non-divided volumes.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Bool_t TestShapeBit(UInt_t f) const
Definition: TGeoShape.h:163
virtual ULong_t SizeOf(const TGeoNode *node, Option_t *option)
computes the total size in bytes of the branch starting with node.
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
Int_t IndexOf(const TObject *obj) const
Definition: TObjArray.cxx:589
virtual void DrawPath(const char *path, Option_t *option="")=0
TNamed()
Definition: TNamed.h:36
void CdTop()
Make top level node the current node.
unsigned long ULong_t
Definition: RtypesCore.h:51
void RegisterMatrix(const TGeoMatrix *matrix)
Register a matrix to the list of matrices.
Int_t AddTransformation(TGeoMatrix *matrix)
Add a matrix to the list. Returns index of the matrix in list.
static RooMathCoreReg dummy
int nentries
Definition: THbookFile.cxx:89
void SetPhiRange(Double_t phimin=0., Double_t phimax=360.)
Set cut phi range.
Bool_t CloseGeometry()
The main geometry must be closed.
Double_t y[n]
Definition: legend1.C:17
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:570
virtual void SetNmeshPoints(Int_t npoints)=0
virtual Int_t GetByteCount() const
Definition: TGeoMedium.h:47
static Bool_t fgLockNavigators
Number of registered threads.
Definition: TGeoManager.h:107
TObjArray * GetListOfPhysicalNodes()
Definition: TGeoManager.h:460
const char * AsString() const
Return the date & time as a string (ctime() format).
Definition: TDatime.cxx:101
TGeoManager * gGeoManager
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.
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
Definition: NeuralNet.icc:545
void SetDefined(Bool_t flag=kTRUE)
Definition: TGeoElement.h:90
Bool_t fUsePWNav
Raytrace mode: 0=normal, 1=pass through, 2=transparent.
Definition: TGeoManager.h:133
Bool_t SetCurrentNavigator(Int_t index)
Switch to another existing navigator for the calling thread.
Bool_t fClosed
Definition: TGeoManager.h:69
void SetTminTmax(Double_t tmin=0, Double_t tmax=999)
Set time cut interval for drawing tracks.
Finder class handling voxels.
virtual void ComputeBBox()=0
Int_t AddShape(const TGeoShape *shape)
Add a shape to the list. Returns index of the shape in list.
Bool_t IsReflection() const
Definition: TGeoMatrix.h:69
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:23
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 ResetAll()
Reset the navigator.
static ThreadsMap_t * fgThreadId
Map between thread id&#39;s and navigator arrays.
Definition: TGeoManager.h:105
Bool_t IsNull() const
Definition: TString.h:383
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void SetVolume(TGeoVolume *volume)
Definition: TGeoNode.h:112
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.
static void CreateDummyMedium()
Create a dummy medium.
Definition: TGeoVolume.cxx:411
virtual void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)=0
void ConvertReflections()
Convert all reflections in geometry to normal rotations + reflected shapes.
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.
TGeoHMatrix * GetHMatrix()
Return stored current matrix (global matrix of the next touched node).
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
constexpr Double_t RadToDeg()
Definition: TMath.h:60
Class providing navigation API for TGeo geometries.
Definition: TGeoNavigator.h:33
void CdNext()
Do a cd to the node found next by FindNextBoundary.
void MasterToTop(const Double_t *master, Double_t *top) const
Convert coordinates from master volume frame to top.
TGeoPNEntry * GetAlignableEntry(const char *name) const
Retrieves an existing alignable object.
Int_t GetMaterialIndex(const char *matname) const
Return index of named material.
void CountLevels()
Count maximum number of nodes per volume, maximum depth and maximum number of xtru vertices...
Int_t GetBombMode() const
Definition: TGeoManager.h:191
Abstract class for geometry painters.
void ClearOverlaps()
Clear the list of overlaps.
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:39
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 ...
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
void SetMaxThreads(Int_t nthreads)
Set maximum number of threads for navigation.
void CheckShapes()
check for wrong parameters in shapes
Definition: TGeoNode.cxx:338
void SetExplodedView(Int_t iopt=0)
Set type of exploding view (see TGeoPainter::SetExplodedView())
virtual void Edit(Option_t *option="")
Append a pad for this geometry.
virtual Bool_t IsRaytracing() const =0
R__EXTERN TGeoIdentity * gGeoIdentity
Definition: TGeoMatrix.h:478
void SetVisLevel(Int_t level=3)
set default level down to which visualization is performed
TGeoNavigator * GetCurrentNavigator() const
Returns current navigator for the calling thread.
TGeoElementTable * fElementTable
clipping shape for raytracing
Definition: TGeoManager.h:116
Bool_t IsVisTouched() const
Definition: TGeoAtt.h:96
void SaveAttributes(const char *filename="tgeoatt.C")
Save current attributes in a macro.
TGeoManager & operator=(const TGeoManager &)
assignment operator
static Int_t ThreadId()
Translates the current thread id to an ordinal number.
Int_t fSizePNEId
array of physical node entries
Definition: TGeoManager.h:126
static TGeoBuilder * Instance(TGeoManager *geom)
Return pointer to singleton.
Definition: TGeoBuilder.cxx:92
virtual void Add(TObject *obj)
Definition: TList.h:87
TGeoVolume * fUserPaintVolume
volume currently painted
Definition: TGeoManager.h:121
TGeoVolume * FindVolumeFast(const char *name, Bool_t multi=kFALSE)
Fast search for a named volume. All trailing blanks stripped.
Bool_t IsSameLocation() const
Definition: TGeoManager.h:392
void BuildIdArray()
Builds node id array.
Definition: TGeoCache.cxx:124
virtual TList * GetListOfKeys() const
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 CdNext()
Do a cd to the node found next by FindNextBoundary.
TObjArray * fRegions
Definition: TGeoManager.h:96
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 BuildDefaultMaterials()
Now just a shortcut for GetElementTable.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
virtual Int_t GetByteCount() const
Definition: TGeoMaterial.h:83
Int_t GetNdaughters() const
Definition: TGeoNode.h:90
virtual void RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol, Bool_t check_norm)=0
void SetAnimateTracks(Bool_t flag=kTRUE)
Definition: TGeoManager.h:537
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 &#39;mat<index>&#39;.
Int_t AddMaterial(const TGeoMaterial *material)
Add a material to the list. Returns index of the material in list.
TGeoNode * FindNode(Bool_t safe_start=kTRUE)
Returns deepest node containing current point.
#define gPad
Definition: TVirtualPad.h:285
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:522
Double_t WeightA() const
Analytical computation of the weight.
Bool_t fMultiThread
Max number of threads.
Definition: TGeoManager.h:131
UChar_t * fBits
Definition: TGeoManager.h:97
TString fParticleName
path to current node
Definition: TGeoManager.h:58
void Add(TObject *obj)
Definition: TObjArray.h:73
Int_t AddTransformation(const TGeoMatrix *matrix)
Add a matrix to the list. Returns index of the matrix in list.
virtual Bool_t IsVolumeMulti() const
Definition: TGeoVolume.h:118
void SetVisibility(Bool_t vis=kTRUE)
Set visibility of the node (obsolete).
Definition: TGeoNode.cxx:685
static Int_t GetMaxXtruVert()
Return maximum number of vertices for an xtru shape used.
Definition: Rtypes.h:59
TGeoVolume * fPaintVolume
Definition: TGeoManager.h:120
void ResetBit(UInt_t f)
Definition: TObject.h:171
unsigned char UChar_t
Definition: RtypesCore.h:34
TGeoElement * GetElement(Int_t z)
Definition: TGeoElement.h:410
virtual void UnbombTranslation(const Double_t *tr, Double_t *bombtr)=0
TGeoParallelWorld * CreateParallelWorld(const char *name)
Create a parallel world for prioritised navigation.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition: TObject.cxx:908
virtual void SetMedium(TGeoMedium *medium)
Definition: TGeoVolume.h:232
void ClearNavigators()
Clear all navigators.
void FindOverlaps() const
loop all nodes marked as overlaps and find overlapping brothers
void UnbombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new &#39;unbombed&#39; translation vector according current exploded view mode.
Int_t GetCurrentNodeId() const
TGeoShape * GetShape() const
Definition: TGeoVolume.h:191
TGeoVolume * Volume(const char *name, const char *shape, Int_t nmed, Float_t *upar, Int_t npar=0)
Create a volume in GEANT3 style.
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.
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual Int_t GetSize() const
Definition: TCollection.h:180
void DoBackupState()
Backup the current state without affecting the cache stack.
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
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...
void SetVisTouched(Bool_t vis=kTRUE)
Mark visualization attributes as "modified".
Definition: TGeoAtt.cxx:131
TGeoVolume * fMasterVolume
top physical node
Definition: TGeoManager.h:112
void SetNumber(Int_t number)
Definition: TGeoVolume.h:235
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
Base class for a flat parallel geometry.
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 TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
virtual void TestOverlaps(const char *path)=0
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
const Bool_t kTRUE
Definition: RtypesCore.h:87
void Grab()
Definition: TGeoVolume.h:142
virtual void CheckPoint(Double_t x=0, Double_t y=0, Double_t z=0, Option_t *option="")=0
void SetVisOption(Int_t option=0)
set drawing mode :
TVirtualGeoPainter * GetGeomPainter()
Make a default painter if none present. Returns pointer to it.
Bool_t OptimizeVoxels()
Perform an extensive sampling to find which type of voxelization is most efficient.
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:94
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.
static void UnlockGeometry()
Unlock current geometry.
Long64_t BinarySearch(Long64_t n, const T *array, T value)
Definition: TMath.h:1092
void CreateThreadData() const
Create thread private data for all geometry objects.
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
char name[80]
Definition: TGX11.cxx:109
Definition: Rtypes.h:60
void BuildInfoBranch()
Builds info branch. Navigation is possible only after this step.
Definition: TGeoCache.cxx:141
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.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute mouse actions on this manager.
void MasterToLocal(const Double_t *master, Double_t *local) const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
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.
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
virtual Bool_t IsEq(const TGeoMaterial *other) const
return true if the other material has the same physical properties
void ClearPhysicalNodes(Bool_t mustdelete=kFALSE)
Clear the current list of physical nodes, so that we can start over with a new list.
void SetNmeshPoints(Int_t npoints=1000)
Set the number of points to be generated on the shape outline when checking for overlaps.
virtual void RecursiveRemove(TObject *obj)
Recursively remove obj from browser.
Definition: TBrowser.cxx:366
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
Bool_t IsRunTimeShape() const
Definition: TGeoShape.h:139
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)...
static Int_t fgMaxXtruVert
Maximum number of daughters.
Definition: TGeoManager.h:46
const char * Data() const
Definition: TString.h:345
virtual Bool_t IsAssembly() const
Returns true if the volume is an assembly or a scaled assembly.
void CheckBoundaryReference(Int_t icheck=-1)
Check the boundary errors reference file created by CheckBoundaryErrors method.
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...