Logo ROOT   6.14/05
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 #include "TBufferText.h"
253 
254 #include "TGeoVoxelFinder.h"
255 #include "TGeoElement.h"
256 #include "TGeoMaterial.h"
257 #include "TGeoMedium.h"
258 #include "TGeoMatrix.h"
259 #include "TGeoNode.h"
260 #include "TGeoPhysicalNode.h"
261 #include "TGeoManager.h"
262 #include "TGeoPara.h"
263 #include "TGeoParaboloid.h"
264 #include "TGeoTube.h"
265 #include "TGeoEltu.h"
266 #include "TGeoHype.h"
267 #include "TGeoCone.h"
268 #include "TGeoSphere.h"
269 #include "TGeoArb8.h"
270 #include "TGeoPgon.h"
271 #include "TGeoTrd1.h"
272 #include "TGeoTrd2.h"
273 #include "TGeoTorus.h"
274 #include "TGeoXtru.h"
275 #include "TGeoCompositeShape.h"
276 #include "TGeoBoolNode.h"
277 #include "TGeoBuilder.h"
278 #include "TVirtualGeoPainter.h"
279 #include "TPluginManager.h"
280 #include "TVirtualGeoTrack.h"
281 #include "TQObject.h"
282 #include "TMath.h"
283 #include "TEnv.h"
284 #include "TGeoParallelWorld.h"
285 #include "TGeoRegion.h"
286 
287 // statics and globals
288 
290 
292 
293 std::mutex TGeoManager::fgMutex;
303 
304 ////////////////////////////////////////////////////////////////////////////////
305 /// Default constructor.
306 
308 {
311  fTimeCut = kFALSE;
312  fTmin = 0.;
313  fTmax = 999.;
314  fPhiCut = kFALSE;
315  fPhimin = 0;
316  fPhimax = 360;
317  fDrawExtra = kFALSE;
321  fClosed = kFALSE;
323  fBits = 0;
324  fCurrentNavigator = 0;
325  fMaterials = 0;
326  fHashPNE = 0;
327  fArrayPNE = 0;
328  fMatrices = 0;
329  fNodes = 0;
330  fOverlaps = 0;
331  fRegions = 0;
332  fNNodes = 0;
333  fMaxVisNodes = 10000;
334  fVolumes = 0;
335  fPhysicalNodes = 0;
336  fShapes = 0;
337  fGVolumes = 0;
338  fGShapes = 0;
339  fTracks = 0;
340  fMedia = 0;
341  fNtracks = 0;
342  fNpdg = 0;
343  fPdgNames = 0;
344  memset(fPdgId, 0, 1024*sizeof(Int_t));
345  fCurrentTrack = 0;
346  fCurrentVolume = 0;
347  fTopVolume = 0;
348  fTopNode = 0;
349  fMasterVolume = 0;
350  fPainter = 0;
351  fActivity = kFALSE;
353  fVisDensity = 0.;
354  fVisLevel = 3;
355  fVisOption = 1;
356  fExplodedView = 0;
357  fNsegments = 20;
358  fNLevel = 0;
359  fUniqueVolumes = 0;
360  fNodeIdArray = 0;
361  fClippingShape = 0;
364  fGLMatrix = 0;
365  fPaintVolume = 0;
366  fUserPaintVolume = 0;
367  fElementTable = 0;
368  fHashVolumes = 0;
369  fHashGVolumes = 0;
370  fSizePNEId = 0;
371  fNPNEId = 0;
372  fKeyPNEId = 0;
373  fValuePNEId = 0;
375  fRaytraceMode = 0;
376  fMaxThreads = 0;
377  fUsePWNav = kFALSE;
378  fParallelWorld = 0;
379  ClearThreadsMap();
380  } else {
381  Init();
384  }
385 }
386 
387 ////////////////////////////////////////////////////////////////////////////////
388 /// Constructor.
389 
390 TGeoManager::TGeoManager(const char *name, const char *title)
391  :TNamed(name, title)
392 {
393  if (!gROOT->GetListOfGeometries()->FindObject(this)) gROOT->GetListOfGeometries()->Add(this);
394  if (!gROOT->GetListOfBrowsables()->FindObject(this)) gROOT->GetListOfBrowsables()->Add(this);
395  Init();
396  gGeoIdentity = new TGeoIdentity("Identity");
398  if (fgVerboseLevel>0) Info("TGeoManager","Geometry %s, %s created", GetName(), GetTitle());
399 }
400 
401 ////////////////////////////////////////////////////////////////////////////////
402 /// Initialize manager class.
403 
405 {
406  if (gGeoManager) {
407  Warning("Init","Deleting previous geometry: %s/%s",gGeoManager->GetName(),gGeoManager->GetTitle());
408  delete gGeoManager;
409  if (fgLock) Fatal("Init", "New geometry created while the old one locked !!!");
410  }
411 
412  gGeoManager = this;
414  fTimeCut = kFALSE;
415  fTmin = 0.;
416  fTmax = 999.;
417  fPhiCut = kFALSE;
418  fPhimin = 0;
419  fPhimax = 360;
420  fDrawExtra = kFALSE;
424  fClosed = kFALSE;
426  fBits = new UChar_t[50000]; // max 25000 nodes per volume
427  fCurrentNavigator = 0;
428  fHashPNE = new THashList(256,3);
429  fArrayPNE = 0;
430  fMaterials = new THashList(200,3);
431  fMatrices = new TObjArray(256);
432  fNodes = new TObjArray(30);
433  fOverlaps = new TObjArray(256);
434  fRegions = new TObjArray(256);
435  fNNodes = 0;
436  fMaxVisNodes = 10000;
437  fVolumes = new TObjArray(256);
438  fPhysicalNodes = new TObjArray(256);
439  fShapes = new TObjArray(256);
440  fGVolumes = new TObjArray(256);
441  fGShapes = new TObjArray(256);
442  fTracks = new TObjArray(256);
443  fMedia = new THashList(200,3);
444  fNtracks = 0;
445  fNpdg = 0;
446  fPdgNames = 0;
447  memset(fPdgId, 0, 1024*sizeof(Int_t));
448  fCurrentTrack = 0;
449  fCurrentVolume = 0;
450  fTopVolume = 0;
451  fTopNode = 0;
452  fMasterVolume = 0;
453  fPainter = 0;
454  fActivity = kFALSE;
456  fVisDensity = 0.;
457  fVisLevel = 3;
458  fVisOption = 1;
459  fExplodedView = 0;
460  fNsegments = 20;
461  fNLevel = 0;
462  fUniqueVolumes = new TObjArray(256);
463  fNodeIdArray = 0;
464  fClippingShape = 0;
467  fGLMatrix = new TGeoHMatrix();
468  fPaintVolume = 0;
469  fUserPaintVolume = 0;
470  fElementTable = 0;
471  fHashVolumes = 0;
472  fHashGVolumes = 0;
473  fSizePNEId = 0;
474  fNPNEId = 0;
475  fKeyPNEId = 0;
476  fValuePNEId = 0;
478  fRaytraceMode = 0;
479  fMaxThreads = 0;
480  fUsePWNav = kFALSE;
481  fParallelWorld = 0;
482  ClearThreadsMap();
483 }
484 
485 ////////////////////////////////////////////////////////////////////////////////
486 ///copy constructor
487 
489  TNamed(gm),
490  fPhimin(gm.fPhimin),
491  fPhimax(gm.fPhimax),
492  fTmin(gm.fTmin),
493  fTmax(gm.fTmax),
494  fNNodes(gm.fNNodes),
499  fVisLevel(gm.fVisLevel),
501  fNtracks(gm.fNtracks),
504  fNpdg(gm.fNpdg),
505  fClosed(gm.fClosed),
510  fPhiCut(gm.fPhiCut),
511  fTimeCut(gm.fTimeCut),
515  fActivity(gm.fActivity),
517  fPainter(gm.fPainter),
518  fMatrices(gm.fMatrices),
519  fShapes(gm.fShapes),
520  fVolumes(gm.fVolumes),
522  fGShapes(gm.fGShapes),
523  fGVolumes(gm.fGVolumes),
524  fTracks(gm.fTracks),
525  fPdgNames(gm.fPdgNames),
527  fMedia(gm.fMedia),
528  fNodes(gm.fNodes),
529  fOverlaps(gm.fOverlaps),
530  fRegions(gm.fRegions),
531  fBits(gm.fBits),
535  fTopNode(gm.fTopNode),
537  fGLMatrix(gm.fGLMatrix),
542  fNLevel(gm.fNLevel),
547  fHashPNE(gm.fHashPNE),
548  fArrayPNE(gm.fArrayPNE),
549  fSizePNEId(0),
550  fNPNEId(0),
551  fKeyPNEId(0),
552  fValuePNEId(0),
553  fMaxThreads(0),
555  fRaytraceMode(0),
556  fUsePWNav(kFALSE),
557  fParallelWorld(0)
558 {
559  for(Int_t i=0; i<1024; i++)
560  fPdgId[i]=gm.fPdgId[i];
562  ClearThreadsMap();
563 }
564 
565 ////////////////////////////////////////////////////////////////////////////////
566 ///assignment operator
567 
569 {
571  if(this!=&gm) {
572  TNamed::operator=(gm);
573  fPhimin=gm.fPhimin;
574  fPhimax=gm.fPhimax;
575  fTmin=gm.fTmin;
576  fTmax=gm.fTmax;
577  fNNodes=gm.fNNodes;
582  fVisLevel=gm.fVisLevel;
584  fNtracks=gm.fNtracks;
587  fNpdg=gm.fNpdg;
588  for(Int_t i=0; i<1024; i++)
589  fPdgId[i]=gm.fPdgId[i];
590  fClosed=gm.fClosed;
595  fPhiCut=gm.fPhiCut;
596  fTimeCut=gm.fTimeCut;
600  fActivity=gm.fActivity;
602  fPainter=gm.fPainter;
603  fMatrices=gm.fMatrices;
604  fShapes=gm.fShapes;
605  fVolumes=gm.fVolumes;
607  fGShapes=gm.fGShapes;
608  fGVolumes=gm.fGVolumes;
609  fTracks=gm.fTracks;
610  fPdgNames=gm.fPdgNames;
612  fMedia=gm.fMedia;
613  fNodes=gm.fNodes;
614  fOverlaps=gm.fOverlaps;
615  fRegions=gm.fRegions;
616  fBits=gm.fBits;
620  fTopNode=gm.fTopNode;
622  fGLMatrix=gm.fGLMatrix;
627  fNLevel=gm.fNLevel;
632  fHashPNE=gm.fHashPNE;
633  fArrayPNE=gm.fArrayPNE;
634  fSizePNEId = 0;
635  fNPNEId = 0;
636  fKeyPNEId = 0;
637  fValuePNEId = 0;
639  fRaytraceMode = 0;
640  fMaxThreads = 0;
641  fUsePWNav = kFALSE;
642  fParallelWorld = 0;
643  ClearThreadsMap();
644  ClearThreadData();
645  }
646  return *this;
647 }
648 
649 ////////////////////////////////////////////////////////////////////////////////
650 /// Destructor
651 
653 {
654  if (gGeoManager != this) gGeoManager = this;
656 
657  if (gROOT->GetListOfFiles()) { //in case this function is called from TROOT destructor
658  gROOT->GetListOfGeometries()->Remove(this);
659  gROOT->GetListOfBrowsables()->Remove(this);
660  }
661 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
662 // TIter next(brlist);
663 // TBrowser *browser = 0;
664 // while ((browser=(TBrowser*)next())) browser->RecursiveRemove(this);
665  ClearThreadsMap();
666  ClearThreadData();
667  delete TGeoBuilder::Instance(this);
668  if (fBits) delete [] fBits;
675  if (fMedia) {fMedia->Delete(); SafeDelete(fMedia);}
679  if (fArrayPNE) {delete fArrayPNE;}
681  if (fShapes) {fShapes->Delete(); SafeDelete( fShapes );}
684  if (fTracks) {fTracks->Delete(); SafeDelete( fTracks );}
687  ClearNavigators();
688  CleanGarbage();
689  SafeDelete( fPainter );
691  if (fSizePNEId) {
692  delete [] fKeyPNEId;
693  delete [] fValuePNEId;
694  }
695  delete fParallelWorld;
697  gGeoIdentity = 0;
698  gGeoManager = 0;
699 }
700 
701 ////////////////////////////////////////////////////////////////////////////////
702 /// Add a material to the list. Returns index of the material in list.
703 
705 {
706  return TGeoBuilder::Instance(this)->AddMaterial((TGeoMaterial*)material);
707 }
708 
709 ////////////////////////////////////////////////////////////////////////////////
710 /// Add an illegal overlap/extrusion to the list.
711 
713 {
714  Int_t size = fOverlaps->GetEntriesFast();
715  fOverlaps->Add((TObject*)ovlp);
716  return size;
717 }
718 
719 ////////////////////////////////////////////////////////////////////////////////
720 /// Add a new region of volumes.
722 {
723  Int_t size = fRegions->GetEntriesFast();
724  fRegions->Add(region);
725  return size;
726 }
727 
728 ////////////////////////////////////////////////////////////////////////////////
729 /// Add a matrix to the list. Returns index of the matrix in list.
730 
732 {
733  return TGeoBuilder::Instance(this)->AddTransformation((TGeoMatrix*)matrix);
734 }
735 
736 ////////////////////////////////////////////////////////////////////////////////
737 /// Add a shape to the list. Returns index of the shape in list.
738 
740 {
741  return TGeoBuilder::Instance(this)->AddShape((TGeoShape*)shape);
742 }
743 
744 ////////////////////////////////////////////////////////////////////////////////
745 /// Add a track to the list of tracks. Use this for primaries only. For secondaries,
746 /// add them to the parent track. The method create objects that are registered
747 /// to the analysis manager but have to be cleaned-up by the user via ClearTracks().
748 
750 {
751  Int_t index = fNtracks;
752  fTracks->AddAtAndExpand(GetGeomPainter()->AddTrack(id,pdgcode,particle),fNtracks++);
753  return index;
754 }
755 
756 ////////////////////////////////////////////////////////////////////////////////
757 /// Add a track to the list of tracks
758 
760 {
761  Int_t index = fNtracks;
762  fTracks->AddAtAndExpand(track,fNtracks++);
763  return index;
764 }
765 
766 ////////////////////////////////////////////////////////////////////////////////
767 /// Makes a primary track but do not attach it to the list of tracks. The track
768 /// can be attached as daughter to another one with TVirtualGeoTrack::AddTrack
769 
771 {
772  TVirtualGeoTrack *track = GetGeomPainter()->AddTrack(id,pdgcode,particle);
773  return track;
774 }
775 
776 ////////////////////////////////////////////////////////////////////////////////
777 /// Add a volume to the list. Returns index of the volume in list.
778 
780 {
781  if (!volume) {
782  Error("AddVolume", "invalid volume");
783  return -1;
784  }
786  if (!uid) uid++;
787  if (!fCurrentVolume) {
788  fCurrentVolume = volume;
789  fUniqueVolumes->AddAtAndExpand(volume,uid);
790  } else {
791  if (!strcmp(volume->GetName(), fCurrentVolume->GetName())) {
792  uid = fCurrentVolume->GetNumber();
793  } else {
794  fCurrentVolume = volume;
795  Int_t olduid = GetUID(volume->GetName());
796  if (olduid<0) {
797  fUniqueVolumes->AddAtAndExpand(volume,uid);
798  } else {
799  uid = olduid;
800  }
801  }
802  }
803  volume->SetNumber(uid);
804  if (!fHashVolumes) {
805  fHashVolumes = new THashList(256);
806  fHashGVolumes = new THashList(256);
807  }
808  TObjArray *list = fVolumes;
809  if (!volume->GetShape() || volume->IsRunTime() || volume->IsVolumeMulti()) {
810  list = fGVolumes;
811  fHashGVolumes->Add(volume);
812  } else {
813  fHashVolumes->Add(volume);
814  }
815  Int_t index = list->GetEntriesFast();
816  list->AddAtAndExpand(volume,index);
817  return uid;
818 }
819 
820 ////////////////////////////////////////////////////////////////////////////////
821 /// Add a navigator in the list of navigators. If it is the first one make it
822 /// current navigator.
823 
825 {
826  if (fMultiThread) { TGeoManager::ThreadId(); fgMutex.lock(); }
827  std::thread::id threadId = std::this_thread::get_id();
828  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
829  TGeoNavigatorArray *array = 0;
830  if (it != fNavigators.end()) array = it->second;
831  else {
832  array = new TGeoNavigatorArray(this);
833  fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
834  }
835  TGeoNavigator *nav = array->AddNavigator();
836  if (fClosed) nav->GetCache()->BuildInfoBranch();
837  if (fMultiThread) fgMutex.unlock();
838  return nav;
839 }
840 
841 ////////////////////////////////////////////////////////////////////////////////
842 /// Returns current navigator for the calling thread.
843 
845 {
846  TTHREAD_TLS(TGeoNavigator*) tnav = 0;
847  if (!fMultiThread) return fCurrentNavigator;
848  TGeoNavigator *nav = tnav; // TTHREAD_TLS_GET(TGeoNavigator*,tnav);
849  if (nav) return nav;
850  std::thread::id threadId = std::this_thread::get_id();
851  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
852  if (it == fNavigators.end()) return 0;
853  TGeoNavigatorArray *array = it->second;
854  nav = array->GetCurrentNavigator();
855  tnav = nav; // TTHREAD_TLS_SET(TGeoNavigator*,tnav,nav);
856  return nav;
857 }
858 
859 ////////////////////////////////////////////////////////////////////////////////
860 /// Get list of navigators for the calling thread.
861 
863 {
864  std::thread::id threadId = std::this_thread::get_id();
865  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
866  if (it == fNavigators.end()) return 0;
867  TGeoNavigatorArray *array = it->second;
868  return array;
869 }
870 
871 ////////////////////////////////////////////////////////////////////////////////
872 /// Switch to another existing navigator for the calling thread.
873 
875 {
876  std::thread::id threadId = std::this_thread::get_id();
877  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
878  if (it == fNavigators.end()) {
879  Error("SetCurrentNavigator", "No navigator defined for this thread\n");
880  std::cout << " thread id: " << threadId << std::endl;
881  return kFALSE;
882  }
883  TGeoNavigatorArray *array = it->second;
884  TGeoNavigator *nav = array->SetCurrentNavigator(index);
885  if (!nav) {
886  Error("SetCurrentNavigator", "Navigator %d not existing for this thread\n", index);
887  std::cout << " thread id: " << threadId << std::endl;
888  return kFALSE;
889  }
890  if (!fMultiThread) fCurrentNavigator = nav;
891  return kTRUE;
892 }
893 
894 ////////////////////////////////////////////////////////////////////////////////
895 /// Set the lock for navigators.
896 
898 {
899  fgLockNavigators = flag;
900 }
901 
902 ////////////////////////////////////////////////////////////////////////////////
903 /// Clear all navigators.
904 
906 {
907  if (fMultiThread) fgMutex.lock();
908  TGeoNavigatorArray *arr = 0;
909  for (NavigatorsMap_t::iterator it = fNavigators.begin();
910  it != fNavigators.end(); ++it) {
911  arr = (*it).second;
912  if (arr) delete arr;
913  }
914  fNavigators.clear();
915  if (fMultiThread) fgMutex.unlock();
916 }
917 
918 ////////////////////////////////////////////////////////////////////////////////
919 /// Clear a single navigator.
920 
922 {
923  if (fMultiThread) fgMutex.lock();
924  for (NavigatorsMap_t::iterator it = fNavigators.begin(); it != fNavigators.end(); ++it) {
925  TGeoNavigatorArray *arr = (*it).second;
926  if (arr) {
927  if ((TGeoNavigator*)arr->Remove((TObject*)nav)) {
928  delete nav;
929  if (!arr->GetEntries()) fNavigators.erase(it);
930  if (fMultiThread) fgMutex.unlock();
931  return;
932  }
933  }
934  }
935  Error("Remove navigator", "Navigator %p not found", nav);
936  if (fMultiThread) fgMutex.unlock();
937 }
938 
939 ////////////////////////////////////////////////////////////////////////////////
940 /// Set maximum number of threads for navigation.
941 
943 {
944  if (!fClosed) {
945  Error("SetMaxThreads", "Cannot set maximum number of threads before closing the geometry");
946  return;
947  }
948  if (!fMultiThread) {
950  std::thread::id threadId = std::this_thread::get_id();
951  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
952  if (it != fNavigators.end()) {
953  TGeoNavigatorArray *array = it->second;
954  fNavigators.erase(it);
955  fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
956  }
957  }
958  if (fMaxThreads) {
959  ClearThreadsMap();
960  ClearThreadData();
961  }
962  fMaxThreads = nthreads+1;
963  if (fMaxThreads>0) {
966  }
967 }
968 
969 ////////////////////////////////////////////////////////////////////////////////
970 
972 {
973  if (!fMaxThreads) return;
974  fgMutex.lock();
975  TIter next(fVolumes);
976  TGeoVolume *vol;
977  while ((vol=(TGeoVolume*)next())) vol->ClearThreadData();
978  fgMutex.unlock();
979 }
980 
981 ////////////////////////////////////////////////////////////////////////////////
982 /// Create thread private data for all geometry objects.
983 
985 {
986  if (!fMaxThreads) return;
987  fgMutex.lock();
988  TIter next(fVolumes);
989  TGeoVolume *vol;
990  while ((vol=(TGeoVolume*)next())) vol->CreateThreadData(fMaxThreads);
991  fgMutex.unlock();
992 }
993 
994 ////////////////////////////////////////////////////////////////////////////////
995 /// Clear the current map of threads. This will be filled again by the calling
996 /// threads via ThreadId calls.
997 
999 {
1000  if (gGeoManager && !gGeoManager->IsMultiThread()) return;
1001  fgMutex.lock();
1002  if (!fgThreadId->empty()) fgThreadId->clear();
1003  fgNumThreads = 0;
1004  fgMutex.unlock();
1005 }
1006 
1007 ////////////////////////////////////////////////////////////////////////////////
1008 /// Translates the current thread id to an ordinal number. This can be used to
1009 /// manage data which is specific for a given thread.
1010 
1012 {
1013  TTHREAD_TLS(Int_t) tid = -1;
1014  Int_t ttid = tid; // TTHREAD_TLS_GET(Int_t,tid);
1015  if (ttid > -1) return ttid;
1016  if (gGeoManager && !gGeoManager->IsMultiThread()) return 0;
1017  std::thread::id threadId = std::this_thread::get_id();
1018  TGeoManager::ThreadsMapIt_t it = fgThreadId->find(threadId);
1019  if (it != fgThreadId->end()) return it->second;
1020  // Map needs to be updated.
1021  fgMutex.lock();
1022  (*fgThreadId)[threadId] = fgNumThreads;
1023  tid = fgNumThreads; // TTHREAD_TLS_SET(Int_t,tid,fgNumThreads);
1024  ttid = fgNumThreads++;
1025  fgMutex.unlock();
1026  return ttid;
1027 }
1028 
1029 ////////////////////////////////////////////////////////////////////////////////
1030 /// Describe how to browse this object.
1031 
1033 {
1034  if (!b) return;
1035  if (fMaterials) b->Add(fMaterials, "Materials");
1036  if (fMedia) b->Add(fMedia, "Media");
1037  if (fMatrices) b->Add(fMatrices, "Local transformations");
1038  if (fOverlaps) b->Add(fOverlaps, "Illegal overlaps");
1039  if (fTracks) b->Add(fTracks, "Tracks");
1040  if (fMasterVolume) b->Add(fMasterVolume, "Master Volume", fMasterVolume->IsVisible());
1041  if (fTopVolume) b->Add(fTopVolume, "Top Volume", fTopVolume->IsVisible());
1042  if (fTopNode) b->Add(fTopNode);
1043  TString browserImp(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
1044  TQObject::Connect(browserImp.Data(), "Checked(TObject*,Bool_t)",
1045  "TGeoManager", this, "SetVisibility(TObject*,Bool_t)");
1046 }
1047 
1048 ////////////////////////////////////////////////////////////////////////////////
1049 /// Append a pad for this geometry.
1050 
1052  AppendPad("");
1053  GetGeomPainter()->EditGeometry(option);
1054 }
1055 
1056 ////////////////////////////////////////////////////////////////////////////////
1057 /// Set visibility for a volume.
1058 
1060 {
1061  if(obj->IsA() == TGeoVolume::Class()) {
1062  TGeoVolume *vol = (TGeoVolume *) obj;
1063  vol->SetVisibility(vis);
1064  } else {
1065  if (obj->InheritsFrom(TGeoNode::Class())) {
1066  TGeoNode *node = (TGeoNode *) obj;
1067  node->SetVisibility(vis);
1068  } else return;
1069  }
1071 }
1072 
1073 ////////////////////////////////////////////////////////////////////////////////
1074 /// Get the new 'bombed' translation vector according current exploded view mode.
1075 
1077 {
1078  if (fPainter) fPainter->BombTranslation(tr, bombtr);
1079  return;
1080 }
1081 
1082 ////////////////////////////////////////////////////////////////////////////////
1083 /// Get the new 'unbombed' translation vector according current exploded view mode.
1084 
1086 {
1087  if (fPainter) fPainter->UnbombTranslation(tr, bombtr);
1088  return;
1089 }
1090 
1091 ////////////////////////////////////////////////////////////////////////////////
1092 /// Backup the current state without affecting the cache stack.
1093 
1095 {
1097 }
1098 
1099 ////////////////////////////////////////////////////////////////////////////////
1100 /// Restore a backed-up state without affecting the cache stack.
1101 
1103 {
1105 }
1106 
1107 ////////////////////////////////////////////////////////////////////////////////
1108 /// Register a matrix to the list of matrices. It will be cleaned-up at the
1109 /// destruction TGeoManager.
1110 
1112 {
1113  return TGeoBuilder::Instance(this)->RegisterMatrix((TGeoMatrix*)matrix);
1114 }
1115 
1116 ////////////////////////////////////////////////////////////////////////////////
1117 /// Replaces all occurrences of VORIG with VNEW in the geometry tree. The volume VORIG
1118 /// is not replaced from the list of volumes, but all node referencing it will reference
1119 /// VNEW instead. Returns number of occurrences changed.
1120 
1122 {
1123  Int_t nref = 0;
1124  if (!vorig || !vnew) return nref;
1125  TGeoMedium *morig = vorig->GetMedium();
1126  Bool_t checkmed = kFALSE;
1127  if (morig) checkmed = kTRUE;
1128  TGeoMedium *mnew = vnew->GetMedium();
1129  // Try to limit the damage produced by incorrect usage.
1130  if (!mnew && !vnew->IsAssembly()) {
1131  Error("ReplaceVolume","Replacement volume %s has no medium and it is not an assembly",
1132  vnew->GetName());
1133  return nref;
1134  }
1135  if (mnew && checkmed) {
1136  if (mnew->GetId() != morig->GetId())
1137  Warning("ReplaceVolume","Replacement volume %s has different medium than original volume %s",
1138  vnew->GetName(), vorig->GetName());
1139  checkmed = kFALSE;
1140  }
1141 
1142  // Medium checking now performed only if replacement is an assembly and old volume a real one.
1143  // Check result is dependent on positioning.
1144  Int_t nvol = fVolumes->GetEntriesFast();
1145  Int_t i,j,nd;
1146  Int_t ierr = 0;
1147  TGeoVolume *vol;
1148  TGeoNode *node;
1149  TGeoVoxelFinder *voxels;
1150  for (i=0; i<nvol; i++) {
1151  vol = (TGeoVolume*)fVolumes->At(i);
1152  if (!vol) continue;
1153  if (vol==vorig || vol==vnew) continue;
1154  nd = vol->GetNdaughters();
1155  for (j=0; j<nd; j++) {
1156  node = vol->GetNode(j);
1157  if (node->GetVolume() == vorig) {
1158  if (checkmed) {
1159  mnew = node->GetMotherVolume()->GetMedium();
1160  if (mnew && mnew->GetId()!=morig->GetId()) ierr++;
1161  }
1162  nref++;
1163  if (node->IsOverlapping()) {
1164  node->SetOverlapping(kFALSE);
1165  Info("ReplaceVolume","%s replaced with assembly and declared NON-OVERLAPPING!",node->GetName());
1166  }
1167  node->SetVolume(vnew);
1168  voxels = node->GetMotherVolume()->GetVoxels();
1169  if (voxels) voxels->SetNeedRebuild();
1170  } else {
1171  if (node->GetMotherVolume() == vorig) {
1172  nref++;
1173  node->SetMotherVolume(vnew);
1174  if (node->IsOverlapping()) {
1175  node->SetOverlapping(kFALSE);
1176  Info("ReplaceVolume","%s inside substitute assembly %s declared NON-OVERLAPPING!",node->GetName(),vnew->GetName());
1177  }
1178  }
1179  }
1180  }
1181  }
1182  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",
1183  ierr, vorig->GetName());
1184  return nref;
1185 }
1186 
1187 ////////////////////////////////////////////////////////////////////////////////
1188 /// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1189 
1191 {
1192  TGeoVolume *toTransform = FindVolumeFast(vname);
1193  if (!toTransform) {
1194  Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1195  return 0;
1196  }
1197  Int_t index = fVolumes->IndexOf(toTransform);
1198  Int_t count = 0;
1199  Int_t indmax = fVolumes->GetEntries();
1200  Bool_t replace = kTRUE;
1201  TGeoVolume *transformed;
1202  while (index<indmax) {
1203  if (replace) {
1204  replace = kFALSE;
1205  transformed = TGeoVolumeAssembly::MakeAssemblyFromVolume(toTransform);
1206  if (transformed) {
1207  ReplaceVolume(toTransform, transformed);
1208  count++;
1209  } else {
1210  if (toTransform->IsAssembly())
1211  Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1212  if (!toTransform->GetNdaughters())
1213  Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform", toTransform->GetName());
1214  if (toTransform->IsVolumeMulti())
1215  Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1216  }
1217  }
1218  index++;
1219  if (index >= indmax) return count;
1220  toTransform = (TGeoVolume*)fVolumes->At(index);
1221  if (!strcmp(toTransform->GetName(),vname)) replace = kTRUE;
1222  }
1223  return count;
1224 }
1225 
1226 ////////////////////////////////////////////////////////////////////////////////
1227 /// Create a new volume by dividing an existing one (GEANT3 like)
1228 ///
1229 /// Divides MOTHER into NDIV divisions called NAME
1230 /// along axis IAXIS starting at coordinate value START
1231 /// and having size STEP. The created volumes will have tracking
1232 /// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1233 /// The behavior of the division operation can be triggered using OPTION :
1234 ///
1235 /// OPTION (case insensitive) :
1236 /// - N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1237 /// - NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1238 /// - S - divide all range with given STEP. NDIV is computed and divisions will be centered
1239 /// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1240 /// - SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1241 
1242 TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis,
1243  Int_t ndiv, Double_t start, Double_t step, Int_t numed, Option_t *option)
1244 {
1245  return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1246 }
1247 
1248 ////////////////////////////////////////////////////////////////////////////////
1249 /// Create rotation matrix named 'mat<index>'.
1250 ///
1251 /// - index rotation matrix number
1252 /// - theta1 polar angle for axis X
1253 /// - phi1 azimuthal angle for axis X
1254 /// - theta2 polar angle for axis Y
1255 /// - phi2 azimuthal angle for axis Y
1256 /// - theta3 polar angle for axis Z
1257 /// - phi3 azimuthal angle for axis Z
1258 ///
1259 
1260 void TGeoManager::Matrix(Int_t index, Double_t theta1, Double_t phi1,
1261  Double_t theta2, Double_t phi2,
1262  Double_t theta3, Double_t phi3)
1263 {
1264  TGeoBuilder::Instance(this)->Matrix(index, theta1, phi1, theta2, phi2, theta3, phi3);
1265 }
1266 
1267 ////////////////////////////////////////////////////////////////////////////////
1268 /// Create material with given A, Z and density, having an unique id.
1269 
1271 {
1272  return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1273 
1274 }
1275 
1276 ////////////////////////////////////////////////////////////////////////////////
1277 /// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1278 /// materials defined by arrays A,Z and WMAT, having an unique id.
1279 
1281  Int_t nelem, Float_t *wmat, Int_t uid)
1282 {
1283  return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1284 }
1285 
1286 ////////////////////////////////////////////////////////////////////////////////
1287 /// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1288 /// materials defined by arrays A,Z and WMAT, having an unique id.
1289 
1291  Int_t nelem, Double_t *wmat, Int_t uid)
1292 {
1293  return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1294 }
1295 
1296 ////////////////////////////////////////////////////////////////////////////////
1297 /// Create tracking medium
1298 ///
1299 /// - numed tracking medium number assigned
1300 /// - name tracking medium name
1301 /// - nmat material number
1302 /// - isvol sensitive volume flag
1303 /// - ifield magnetic field
1304 /// - fieldm max. field value (kilogauss)
1305 /// - tmaxfd max. angle due to field (deg/step)
1306 /// - stemax max. step allowed
1307 /// - deemax max. fraction of energy lost in a step
1308 /// - epsil tracking precision (cm)
1309 /// - stmin min. step due to continuous processes (cm)
1310 ///
1311 /// - ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1312 /// - ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1313 /// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1314 ///
1315 
1316 TGeoMedium *TGeoManager::Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol,
1317  Int_t ifield, Double_t fieldm, Double_t tmaxfd,
1318  Double_t stemax, Double_t deemax, Double_t epsil,
1319  Double_t stmin)
1320 {
1321  return TGeoBuilder::Instance(this)->Medium(name, numed, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
1322 }
1323 
1324 ////////////////////////////////////////////////////////////////////////////////
1325 /// Create a node called <name_nr> pointing to the volume called <name>
1326 /// as daughter of the volume called <mother> (gspos). The relative matrix is
1327 /// made of : a translation (x,y,z) and a rotation matrix named <matIROT>.
1328 /// In case npar>0, create the volume to be positioned in mother, according
1329 /// its actual parameters (gsposp).
1330 /// - NAME Volume name
1331 /// - NUMBER Copy number of the volume
1332 /// - MOTHER Mother volume name
1333 /// - X X coord. of the volume in mother ref. sys.
1334 /// - Y Y coord. of the volume in mother ref. sys.
1335 /// - Z Z coord. of the volume in mother ref. sys.
1336 /// - IROT Rotation matrix number w.r.t. mother ref. sys.
1337 /// - ISONLY ONLY/MANY flag
1338 
1339 void TGeoManager::Node(const char *name, Int_t nr, const char *mother,
1340  Double_t x, Double_t y, Double_t z, Int_t irot,
1341  Bool_t isOnly, Float_t *upar, Int_t npar)
1342 {
1343  TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1344 }
1345 
1346 ////////////////////////////////////////////////////////////////////////////////
1347 /// Create a node called <name_nr> pointing to the volume called <name>
1348 /// as daughter of the volume called <mother> (gspos). The relative matrix is
1349 /// made of : a translation (x,y,z) and a rotation matrix named <matIROT>.
1350 /// In case npar>0, create the volume to be positioned in mother, according
1351 /// its actual parameters (gsposp).
1352 /// - NAME Volume name
1353 /// - NUMBER Copy number of the volume
1354 /// - MOTHER Mother volume name
1355 /// - X X coord. of the volume in mother ref. sys.
1356 /// - Y Y coord. of the volume in mother ref. sys.
1357 /// - Z Z coord. of the volume in mother ref. sys.
1358 /// - IROT Rotation matrix number w.r.t. mother ref. sys.
1359 /// - ISONLY ONLY/MANY flag
1360 
1361 void TGeoManager::Node(const char *name, Int_t nr, const char *mother,
1362  Double_t x, Double_t y, Double_t z, Int_t irot,
1363  Bool_t isOnly, Double_t *upar, Int_t npar)
1364 {
1365  TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1366 
1367 }
1368 
1369 ////////////////////////////////////////////////////////////////////////////////
1370 /// Create a volume in GEANT3 style.
1371 /// - NAME Volume name
1372 /// - SHAPE Volume type
1373 /// - NMED Tracking medium number
1374 /// - NPAR Number of shape parameters
1375 /// - UPAR Vector containing shape parameters
1376 
1377 TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed,
1378  Float_t *upar, Int_t npar)
1379 {
1380  return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1381 }
1382 
1383 ////////////////////////////////////////////////////////////////////////////////
1384 /// Create a volume in GEANT3 style.
1385 /// - NAME Volume name
1386 /// - SHAPE Volume type
1387 /// - NMED Tracking medium number
1388 /// - NPAR Number of shape parameters
1389 /// - UPAR Vector containing shape parameters
1390 
1391 TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed,
1392  Double_t *upar, Int_t npar)
1393 {
1394  return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1395 }
1396 
1397 ////////////////////////////////////////////////////////////////////////////////
1398 /// Assigns uid's for all materials,media and matrices.
1399 
1401 {
1402  Int_t index = 1;
1403  TIter next(fMaterials);
1404  TGeoMaterial *mater;
1405  while ((mater=(TGeoMaterial*)next())) {
1406  mater->SetUniqueID(index++);
1408  }
1409  index = 1;
1410  TIter next1(fMedia);
1411  TGeoMedium *med;
1412  while ((med=(TGeoMedium*)next1())) {
1413  med->SetUniqueID(index++);
1415  }
1416  index = 1;
1417  TIter next2(fShapes);
1418  TGeoShape *shape;
1419  while ((shape=(TGeoShape*)next2())) {
1420  shape->SetUniqueID(index++);
1421  if (shape->IsComposite()) ((TGeoCompositeShape*)shape)->GetBoolNode()->RegisterMatrices();
1422  }
1423 
1424  TIter next3(fMatrices);
1425  TGeoMatrix *matrix;
1426  while ((matrix=(TGeoMatrix*)next3())) {
1427  matrix->RegisterYourself();
1428  }
1429  TIter next4(fMatrices);
1430  index = 1;
1431  while ((matrix=(TGeoMatrix*)next4())) {
1432  matrix->SetUniqueID(index++);
1434  }
1435  TIter next5(fVolumes);
1436  TGeoVolume *vol;
1437  while ((vol=(TGeoVolume*)next5())) vol->UnmarkSaved();
1438 }
1439 
1440 ////////////////////////////////////////////////////////////////////////////////
1441 /// Reset all attributes to default ones. Default attributes for visualization
1442 /// are those defined before closing the geometry.
1443 
1445 {
1446  if (gPad) delete gPad;
1447  gPad = 0;
1448  SetVisOption(0);
1449  SetVisLevel(3);
1450  SetExplodedView(0);
1451  SetBombFactors();
1452  if (!gStyle) return;
1453  TIter next(fVolumes);
1454  TGeoVolume *vol = 0;
1455  while ((vol=(TGeoVolume*)next())) {
1456  if (!vol->IsVisTouched()) continue;
1457  vol->SetVisTouched(kFALSE);
1458  }
1459 }
1460 ////////////////////////////////////////////////////////////////////////////////
1461 /// Closing geometry implies checking the geometry validity, fixing shapes
1462 /// with negative parameters (run-time shapes)building the cache manager,
1463 /// voxelizing all volumes, counting the total number of physical nodes and
1464 /// registering the manager class to the browser.
1465 
1467 {
1468  if (fClosed) {
1469  Warning("CloseGeometry", "geometry already closed");
1470  return;
1471  }
1472  if (!fMasterVolume) {
1473  Error("CloseGeometry","you MUST call SetTopVolume() first !");
1474  return;
1475  }
1476  if (!gROOT->GetListOfGeometries()->FindObject(this)) gROOT->GetListOfGeometries()->Add(this);
1477  if (!gROOT->GetListOfBrowsables()->FindObject(this)) gROOT->GetListOfBrowsables()->Add(this);
1478 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1479 // TIter next(brlist);
1480 // TBrowser *browser = 0;
1481 // while ((browser=(TBrowser*)next())) browser->Refresh();
1482  TString opt(option);
1483  opt.ToLower();
1484 // Bool_t dummy = opt.Contains("d");
1485  Bool_t nodeid = opt.Contains("i");
1486  // Create a geometry navigator if not present
1487  TGeoNavigator *nav = 0;
1488  Int_t nnavigators = 0;
1489  // Check if the geometry is streamed from file
1490  if (fIsGeomReading) {
1491  if (fgVerboseLevel>0) Info("CloseGeometry","Geometry loaded from file...");
1493  if (!fElementTable) fElementTable = new TGeoElementTable(200);
1494  if (!fTopNode) {
1495  if (!fMasterVolume) {
1496  Error("CloseGeometry", "Master volume not streamed");
1497  return;
1498  }
1500  if (fStreamVoxels && fgVerboseLevel>0) Info("CloseGeometry","Voxelization retrieved from file");
1501  }
1502  // Create a geometry navigator if not present
1504  nnavigators = GetListOfNavigators()->GetEntriesFast();
1505  Voxelize("ALL");
1506  CountLevels();
1507  for (Int_t i=0; i<nnavigators; i++) {
1508  nav = (TGeoNavigator*)GetListOfNavigators()->At(i);
1509  nav->GetCache()->BuildInfoBranch();
1510  if (nodeid) nav->GetCache()->BuildIdArray();
1511  }
1512  if (!fHashVolumes) {
1513  Int_t nvol = fVolumes->GetEntriesFast();
1514  Int_t ngvol = fGVolumes->GetEntriesFast();
1515  fHashVolumes = new THashList(nvol+1);
1516  fHashGVolumes = new THashList(ngvol+1);
1517  Int_t i;
1518  for (i=0; i<ngvol; i++) fHashGVolumes->AddLast(fGVolumes->At(i));
1519  for (i=0; i<nvol; i++) fHashVolumes->AddLast(fVolumes->At(i));
1520  }
1521  fClosed = kTRUE;
1522  if (fParallelWorld) {
1523  if (fgVerboseLevel>0) Info("CloseGeometry","Recreating parallel world %s ...",fParallelWorld->GetName());
1525  }
1526 
1527  if (fgVerboseLevel>0) Info("CloseGeometry","%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast()-1, GetTitle());
1528  if (fgVerboseLevel>0) Info("CloseGeometry","----------------modeler ready----------------");
1529  return;
1530  }
1531 
1532  // Create a geometry navigator if not present
1534  nnavigators = GetListOfNavigators()->GetEntriesFast();
1536  CheckGeometry();
1537  if (fgVerboseLevel>0) Info("CloseGeometry","Counting nodes...");
1538  fNNodes = CountNodes();
1539  fNLevel = fMasterVolume->CountNodes(1,3)+1;
1540  if (fNLevel<30) fNLevel = 100;
1541 
1542 // BuildIdArray();
1543  Voxelize("ALL");
1544  if (fgVerboseLevel>0) Info("CloseGeometry","Building cache...");
1545  CountLevels();
1546  for (Int_t i=0; i<nnavigators; i++) {
1547  nav = (TGeoNavigator*)GetListOfNavigators()->At(i);
1548  nav->GetCache()->BuildInfoBranch();
1549  if (nodeid) nav->GetCache()->BuildIdArray();
1550  }
1551  fClosed = kTRUE;
1552  if (fgVerboseLevel>0) {
1553  Info("CloseGeometry","%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast()-1, GetTitle());
1554  Info("CloseGeometry","----------------modeler ready----------------");
1555  }
1556 }
1557 
1558 ////////////////////////////////////////////////////////////////////////////////
1559 /// Clear the list of overlaps.
1560 
1562 {
1563  if (fOverlaps) {
1564  fOverlaps->Delete();
1565  delete fOverlaps;
1566  }
1567  fOverlaps = new TObjArray();
1568 }
1569 
1570 ////////////////////////////////////////////////////////////////////////////////
1571 /// Remove a shape from the list of shapes.
1572 
1574 {
1575  if (fShapes->FindObject(shape)) fShapes->Remove((TGeoShape*)shape);
1576  delete shape;
1577 }
1578 
1579 ////////////////////////////////////////////////////////////////////////////////
1580 /// Clean temporary volumes and shapes from garbage collection.
1581 
1583 {
1584  if (!fGVolumes && !fGShapes) return;
1585  Int_t i,nentries;
1586  if (fGVolumes) {
1587  nentries = fGVolumes->GetEntries();
1588  TGeoVolume *vol = 0;
1589  for (i=0; i<nentries; i++) {
1590  vol=(TGeoVolume*)fGVolumes->At(i);
1591  if (vol) vol->SetFinder(0);
1592  }
1593  fGVolumes->Delete();
1594  delete fGVolumes;
1595  fGVolumes = 0;
1596  }
1597  if (fGShapes) {
1598  fGShapes->Delete();
1599  delete fGShapes;
1600  fGShapes = 0;
1601  }
1602 }
1603 
1604 ////////////////////////////////////////////////////////////////////////////////
1605 /// Change current path to point to the node having this id.
1606 /// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1607 
1609 {
1610  GetCurrentNavigator()->CdNode(nodeid);
1611 }
1612 
1613 ////////////////////////////////////////////////////////////////////////////////
1614 /// Get the unique ID of the current node.
1615 
1617 {
1619 }
1620 
1621 ////////////////////////////////////////////////////////////////////////////////
1622 /// Make top level node the current node. Updates the cache accordingly.
1623 /// Determine the overlapping state of current node.
1624 
1626 {
1628 }
1629 
1630 ////////////////////////////////////////////////////////////////////////////////
1631 /// Go one level up in geometry. Updates cache accordingly.
1632 /// Determine the overlapping state of current node.
1633 
1635 {
1637 }
1638 
1639 ////////////////////////////////////////////////////////////////////////////////
1640 /// Make a daughter of current node current. Can be called only with a valid
1641 /// daughter index (no check). Updates cache accordingly.
1642 
1644 {
1645  GetCurrentNavigator()->CdDown(index);
1646 }
1647 
1648 ////////////////////////////////////////////////////////////////////////////////
1649 /// Do a cd to the node found next by FindNextBoundary
1650 
1652 {
1654 }
1655 
1656 ////////////////////////////////////////////////////////////////////////////////
1657 /// Browse the tree of nodes starting from fTopNode according to pathname.
1658 /// Changes the path accordingly.
1659 
1660 Bool_t TGeoManager::cd(const char *path)
1661 {
1662  return GetCurrentNavigator()->cd(path);
1663 }
1664 
1665 ////////////////////////////////////////////////////////////////////////////////
1666 /// Check if a geometry path is valid without changing the state of the current navigator.
1667 
1668 Bool_t TGeoManager::CheckPath(const char *path) const
1669 {
1670  return GetCurrentNavigator()->CheckPath(path);
1671 }
1672 
1673 ////////////////////////////////////////////////////////////////////////////////
1674 /// Convert all reflections in geometry to normal rotations + reflected shapes.
1675 
1677 {
1678  if (!fTopNode) return;
1679  if (fgVerboseLevel>0) Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1680  TGeoIterator next(fTopVolume);
1681  TGeoNode *node;
1682  TGeoNodeMatrix *nodematrix;
1683  TGeoMatrix *matrix, *mclone;
1684  TGeoVolume *reflected;
1685  while ((node=next())) {
1686  matrix = node->GetMatrix();
1687  if (matrix->IsReflection()) {
1688 // printf("%s before\n", node->GetName());
1689 // matrix->Print();
1690  mclone = new TGeoCombiTrans(*matrix);
1691  mclone->RegisterYourself();
1692  // Reflect just the rotation component
1693  mclone->ReflectZ(kFALSE, kTRUE);
1694  nodematrix = (TGeoNodeMatrix*)node;
1695  nodematrix->SetMatrix(mclone);
1696 // printf("%s after\n", node->GetName());
1697 // node->GetMatrix()->Print();
1698  reflected = node->GetVolume()->MakeReflectedVolume();
1699  node->SetVolume(reflected);
1700  }
1701  }
1702  if (fgVerboseLevel>0) Info("ConvertReflections", "Done");
1703 }
1704 
1705 ////////////////////////////////////////////////////////////////////////////////
1706 /// Count maximum number of nodes per volume, maximum depth and maximum
1707 /// number of xtru vertices.
1708 
1710 {
1711  if (!fTopNode) {
1712  Error("CountLevels", "Top node not defined.");
1713  return;
1714  }
1715  TGeoIterator next(fTopVolume);
1716  Bool_t fixrefs = fIsGeomReading && (fMasterVolume->GetRefCount()==1);
1718  if (fgVerboseLevel>1 && fixrefs) Info("CountLevels", "Fixing volume reference counts");
1719  TGeoNode *node;
1720  Int_t maxlevel = 1;
1721  Int_t maxnodes = fTopVolume->GetNdaughters();
1722  Int_t maxvertices = 1;
1723  while ((node=next())) {
1724  if (fixrefs) {
1725  node->GetVolume()->Grab();
1726  for (Int_t ibit=10; ibit<14; ibit++) {
1727  node->SetBit(BIT(ibit+4), node->TestBit(BIT(ibit)));
1728 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1729  }
1730  }
1731  if (node->GetVolume()->GetVoxels()) {
1732  if (node->GetNdaughters()>maxnodes) maxnodes = node->GetNdaughters();
1733  }
1734  if (next.GetLevel()>maxlevel) maxlevel = next.GetLevel();
1735  if (node->GetVolume()->GetShape()->IsA()==TGeoXtru::Class()) {
1736  TGeoXtru *xtru = (TGeoXtru*)node->GetVolume()->GetShape();
1737  if (xtru->GetNvert()>maxvertices) maxvertices = xtru->GetNvert();
1738  }
1739  }
1740  fgMaxLevel = maxlevel;
1741  fgMaxDaughters = maxnodes;
1742  fgMaxXtruVert = maxvertices;
1743  if (fgVerboseLevel>0) Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1744 }
1745 
1746 ////////////////////////////////////////////////////////////////////////////////
1747 /// Count the total number of nodes starting from a volume, nlevels down.
1748 
1750 {
1751  TGeoVolume *top;
1752  if (!vol) {
1753  top = fTopVolume;
1754  } else {
1755  top = (TGeoVolume*)vol;
1756  }
1757  Int_t count = top->CountNodes(nlevels, option);
1758  return count;
1759 }
1760 
1761 ////////////////////////////////////////////////////////////////////////////////
1762 /// Set default angles for a given view.
1763 
1765 {
1767 }
1768 
1769 ////////////////////////////////////////////////////////////////////////////////
1770 /// Draw current point in the same view.
1771 
1773 {
1774  if (fPainter) fPainter->DrawCurrentPoint(color);
1775 }
1776 
1777 ////////////////////////////////////////////////////////////////////////////////
1778 /// Draw animation of tracks
1779 
1780 void TGeoManager::AnimateTracks(Double_t tmin, Double_t tmax, Int_t nframes, Option_t *option)
1781 {
1782  SetAnimateTracks();
1783  GetGeomPainter();
1784  if (tmin<0 || tmin>=tmax || nframes<1) return;
1786  box[0] = box[1] = box[2] = 0;
1787  box[3] = box[4] = box[5] = 100;
1788  Double_t dt = (tmax-tmin)/Double_t(nframes);
1789  Double_t delt = 2E-9;
1790  Double_t t = tmin;
1791  Int_t i, j;
1792  TString opt(option);
1793  Bool_t save = kFALSE, geomanim=kFALSE;
1794  TString fname;
1795  if (opt.Contains("/S")) save = kTRUE;
1796 
1797  if (opt.Contains("/G")) geomanim = kTRUE;
1798  SetTminTmax(0,0);
1799  DrawTracks(opt.Data());
1800  Double_t start[6], end[6];
1801  Double_t dd[6] = {0,0,0,0,0,0};
1802  Double_t dlat=0, dlong=0, dpsi=0;
1803  if (geomanim) {
1804  fPainter->EstimateCameraMove(tmin+5*dt, tmin+15*dt, start, end);
1805  for (i=0; i<3; i++) {
1806  start[i+3] = 20 + 1.3*start[i+3];
1807  end[i+3] = 20 + 0.9*end[i+3];
1808  }
1809  for (i=0; i<6; i++) {
1810  dd[i] = (end[i]-start[i])/10.;
1811  }
1812  memcpy(box, start, 6*sizeof(Double_t));
1813  fPainter->GetViewAngles(dlong,dlat,dpsi);
1814  dlong = (-206-dlong)/Double_t(nframes);
1815  dlat = (126-dlat)/Double_t(nframes);
1816  dpsi = (75-dpsi)/Double_t(nframes);
1817  fPainter->GrabFocus();
1818  }
1819 
1820  for (i=0; i<nframes; i++) {
1821  if (t-delt<0) SetTminTmax(t-delt,t);
1822  else gGeoManager->SetTminTmax(t-delt,t);
1823  if (geomanim) {
1824  for (j=0; j<6; j++) box[j]+=dd[j];
1825  fPainter->GrabFocus(1,dlong,dlat,dpsi);
1826  } else {
1827  ModifiedPad();
1828  }
1829  if (save) {
1830  fname = TString::Format("anim%04d.gif", i);
1831  gPad->Print(fname);
1832  }
1833  t += dt;
1834  }
1836 }
1837 
1838 ////////////////////////////////////////////////////////////////////////////////
1839 /// Draw tracks over the geometry, according to option. By default, only
1840 /// primaries are drawn. See TGeoTrack::Draw() for additional options.
1841 
1843 {
1844  TVirtualGeoTrack *track;
1845  //SetVisLevel(1);
1846  //SetVisOption(1);
1847  SetAnimateTracks();
1848  for (Int_t i=0; i<fNtracks; i++) {
1849  track = GetTrack(i);
1850  if (track) track->Draw(option);
1851  }
1853  ModifiedPad();
1854 }
1855 
1856 ////////////////////////////////////////////////////////////////////////////////
1857 /// Draw current path
1858 
1859 void TGeoManager::DrawPath(const char *path, Option_t *option)
1860 {
1861  if (!fTopVolume) return;
1863  GetGeomPainter()->DrawPath(path, option);
1864 }
1865 
1866 ////////////////////////////////////////////////////////////////////////////////
1867 /// Draw random points in the bounding box of a volume.
1868 
1869 void TGeoManager::RandomPoints(const TGeoVolume *vol, Int_t npoints, Option_t *option)
1870 {
1871  GetGeomPainter()->RandomPoints((TGeoVolume*)vol, npoints, option);
1872 }
1873 
1874 ////////////////////////////////////////////////////////////////////////////////
1875 /// Check time of finding "Where am I" for n points.
1876 
1877 void TGeoManager::Test(Int_t npoints, Option_t *option)
1878 {
1879  GetGeomPainter()->Test(npoints, option);
1880 }
1881 
1882 ////////////////////////////////////////////////////////////////////////////////
1883 /// Geometry overlap checker based on sampling.
1884 
1885 void TGeoManager::TestOverlaps(const char* path)
1886 {
1887  GetGeomPainter()->TestOverlaps(path);
1888 }
1889 
1890 ////////////////////////////////////////////////////////////////////////////////
1891 /// Fill volume names of current branch into an array.
1892 
1894 {
1896 }
1897 
1898 ////////////////////////////////////////////////////////////////////////////////
1899 /// Get name for given pdg code;
1900 
1901 const char *TGeoManager::GetPdgName(Int_t pdg) const
1902 {
1903  static char defaultname[5] = { "XXX" };
1904  if (!fPdgNames || !pdg) return defaultname;
1905  for (Int_t i=0; i<fNpdg; i++) {
1906  if (fPdgId[i]==pdg) return fPdgNames->At(i)->GetName();
1907  }
1908  return defaultname;
1909 }
1910 
1911 ////////////////////////////////////////////////////////////////////////////////
1912 /// Set a name for a particle having a given pdg.
1913 
1914 void TGeoManager::SetPdgName(Int_t pdg, const char *name)
1915 {
1916  if (!pdg) return;
1917  if (!fPdgNames) {
1918  fPdgNames = new TObjArray(1024);
1919  }
1920  if (!strcmp(name, GetPdgName(pdg))) return;
1921  // store pdg name
1922  if (fNpdg>1023) {
1923  Warning("SetPdgName", "No more than 256 different pdg codes allowed");
1924  return;
1925  }
1926  fPdgId[fNpdg] = pdg;
1927  TNamed *pdgname = new TNamed(name, "");
1928  fPdgNames->AddAtAndExpand(pdgname, fNpdg++);
1929 }
1930 
1931 ////////////////////////////////////////////////////////////////////////////////
1932 /// Fill node copy numbers of current branch into an array.
1933 
1934 void TGeoManager::GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
1935 {
1936  GetCurrentNavigator()->GetBranchNumbers(copyNumbers, volumeNumbers);
1937 }
1938 
1939 ////////////////////////////////////////////////////////////////////////////////
1940 /// Fill node copy numbers of current branch into an array.
1941 
1943 {
1945 }
1946 
1947 ////////////////////////////////////////////////////////////////////////////////
1948 /// Retrieve cartesian and radial bomb factors.
1949 
1950 void TGeoManager::GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
1951 {
1952  if (fPainter) {
1953  fPainter->GetBombFactors(bombx, bomby, bombz, bombr);
1954  return;
1955  }
1956  bombx = bomby = bombz = bombr = 1.3;
1957 }
1958 
1959 ////////////////////////////////////////////////////////////////////////////////
1960 /// Return maximum number of daughters of a volume used in the geometry.
1961 
1963 {
1964  return fgMaxDaughters;
1965 }
1966 
1967 ////////////////////////////////////////////////////////////////////////////////
1968 /// Return maximum number of levels used in the geometry.
1969 
1971 {
1972  return fgMaxLevel;
1973 }
1974 
1975 ////////////////////////////////////////////////////////////////////////////////
1976 /// Return maximum number of vertices for an xtru shape used.
1977 
1979 {
1980  return fgMaxXtruVert;
1981 }
1982 
1983 ////////////////////////////////////////////////////////////////////////////////
1984 /// Returns number of threads that were set to use geometry.
1985 
1987 {
1988  return fgNumThreads;
1989 }
1990 
1991 ////////////////////////////////////////////////////////////////////////////////
1992 /// Return stored current matrix (global matrix of the next touched node).
1993 
1995 {
1996  if (!GetCurrentNavigator()) return NULL;
1997  return GetCurrentNavigator()->GetHMatrix();
1998 }
1999 
2000 ////////////////////////////////////////////////////////////////////////////////
2001 /// Returns current depth to which geometry is drawn.
2002 
2004 {
2005  return fVisLevel;
2006 }
2007 
2008 ////////////////////////////////////////////////////////////////////////////////
2009 /// Returns current depth to which geometry is drawn.
2010 
2012 {
2013  return fVisOption;
2014 }
2015 
2016 ////////////////////////////////////////////////////////////////////////////////
2017 /// Find level of virtuality of current overlapping node (number of levels
2018 /// up having the same tracking media.
2019 
2021 {
2023 }
2024 
2025 ////////////////////////////////////////////////////////////////////////////////
2026 /// Search the track hierarchy to find the track with the
2027 /// given id
2028 ///
2029 /// if 'primsFirst' is true, then:
2030 /// first tries TGeoManager::GetTrackOfId, then does a
2031 /// recursive search if that fails. this would be faster
2032 /// if the track is somehow known to be a primary
2033 
2035 {
2036  TVirtualGeoTrack* trk = 0;
2037  trk = GetTrackOfId(id);
2038  if (trk) return trk;
2039  // need recursive search
2040  TIter next(fTracks);
2041  TVirtualGeoTrack* prim;
2042  while ((prim = (TVirtualGeoTrack*)next())) {
2043  trk = prim->FindTrackWithId(id);
2044  if (trk) return trk;
2045  }
2046  return NULL;
2047 }
2048 
2049 ////////////////////////////////////////////////////////////////////////////////
2050 /// Get track with a given ID.
2051 
2053 {
2054  TVirtualGeoTrack *track;
2055  for (Int_t i=0; i<fNtracks; i++) {
2056  if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2057  if (track->GetId() == id) return track;
2058  }
2059  }
2060  return 0;
2061 }
2062 
2063 ////////////////////////////////////////////////////////////////////////////////
2064 /// Get parent track with a given ID.
2065 
2067 {
2069  while ((track=track->GetMother())) {
2070  if (track->GetId()==id) return track;
2071  }
2072  return 0;
2073 }
2074 
2075 ////////////////////////////////////////////////////////////////////////////////
2076 /// Get index for track id, -1 if not found.
2077 
2079 {
2080  TVirtualGeoTrack *track;
2081  for (Int_t i=0; i<fNtracks; i++) {
2082  if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2083  if (track->GetId() == id) return i;
2084  }
2085  }
2086  return -1;
2087 }
2088 
2089 ////////////////////////////////////////////////////////////////////////////////
2090 /// Go upwards the tree until a non-overlapping node
2091 
2093 {
2094  return GetCurrentNavigator()->GotoSafeLevel();
2095 }
2096 
2097 ////////////////////////////////////////////////////////////////////////////////
2098 /// Go upwards the tree until a non-overlapping node
2099 
2101 {
2102  return GetCurrentNavigator()->GetSafeLevel();
2103 }
2104 
2105 ////////////////////////////////////////////////////////////////////////////////
2106 /// Set default volume colors according to A of material
2107 
2109 {
2110  const Int_t nmax = 110;
2111  Int_t col[nmax];
2112  for (Int_t i=0;i<nmax;i++) col[i] = kGray;
2113 
2114  //here we should create a new TColor with the same rgb as in the default
2115  //ROOT colors used below
2116  col[ 3] = kYellow-10;
2117  col[ 4] = col[ 5] = kGreen-10;
2118  col[ 6] = col[ 7] = kBlue-7;
2119  col[ 8] = col[ 9] = kMagenta-3;
2120  col[10] = col[11] = kRed-10;
2121  col[12] = kGray+1;
2122  col[13] = kBlue-10;
2123  col[14] = kOrange+7;
2124  col[16] = kYellow+1;
2125  col[20] = kYellow-10;
2126  col[24] = col[25] = col[26] = kBlue-8;
2127  col[29] = kOrange+9;
2128  col[79] = kOrange-2;
2129 
2130  TGeoVolume *vol;
2131  TIter next(fVolumes);
2132  while ((vol=(TGeoVolume*)next())) {
2133  TGeoMedium *med = vol->GetMedium();
2134  if (!med) continue;
2135  TGeoMaterial *mat = med->GetMaterial();
2136  Int_t matZ = (Int_t)mat->GetZ();
2137  vol->SetLineColor(col[matZ]);
2138  if (mat->GetDensity()<0.1) vol->SetTransparency(60);
2139  }
2140 }
2141 
2142 ////////////////////////////////////////////////////////////////////////////////
2143 /// Compute safe distance from the current point. This represent the distance
2144 /// from POINT to the closest boundary.
2145 
2147 {
2148  return GetCurrentNavigator()->Safety(inside);
2149 }
2150 
2151 ////////////////////////////////////////////////////////////////////////////////
2152 /// Set volume attributes in G3 style.
2153 
2154 void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2155 {
2156  TGeoVolume *volume;
2157  Bool_t all = kFALSE;
2158  if (strstr(name,"*")) all=kTRUE;
2159  Int_t ivo=0;
2160  TIter next(fVolumes);
2161  TString chatt = att;
2162  chatt.ToLower();
2163  while ((volume=(TGeoVolume*)next())) {
2164  if (strcmp(volume->GetName(), name) && !all) continue;
2165  ivo++;
2166  if (chatt.Contains("colo")) volume->SetLineColor(val);
2167  if (chatt.Contains("lsty")) volume->SetLineStyle(val);
2168  if (chatt.Contains("lwid")) volume->SetLineWidth(val);
2169  if (chatt.Contains("fill")) volume->SetFillColor(val);
2170  if (chatt.Contains("seen")) volume->SetVisibility(val);
2171  }
2172  TIter next1(fGVolumes);
2173  while ((volume=(TGeoVolume*)next1())) {
2174  if (strcmp(volume->GetName(), name) && !all) continue;
2175  ivo++;
2176  if (chatt.Contains("colo")) volume->SetLineColor(val);
2177  if (chatt.Contains("lsty")) volume->SetLineStyle(val);
2178  if (chatt.Contains("lwid")) volume->SetLineWidth(val);
2179  if (chatt.Contains("fill")) volume->SetFillColor(val);
2180  if (chatt.Contains("seen")) volume->SetVisibility(val);
2181  }
2182  if (!ivo) {
2183  Warning("SetVolumeAttribute","volume: %s does not exist",name);
2184  }
2185 }
2186 
2187 ////////////////////////////////////////////////////////////////////////////////
2188 /// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2189 
2191 {
2192  if (fPainter) fPainter->SetBombFactors(bombx, bomby, bombz, bombr);
2193 }
2194 
2195 ////////////////////////////////////////////////////////////////////////////////
2196 /// Set a user-defined shape as clipping for ray tracing.
2197 
2199 {
2200  TVirtualGeoPainter *painter = GetGeomPainter();
2201  if (shape) {
2203  fClippingShape = shape;
2204  }
2205  painter->SetClippingShape(shape);
2206 }
2207 
2208 ////////////////////////////////////////////////////////////////////////////////
2209 /// set the maximum number of visible nodes.
2210 
2212  fMaxVisNodes = maxnodes;
2213  if (maxnodes>0 && fgVerboseLevel>0)
2214  Info("SetMaxVisNodes","Automatic visible depth for %d visible nodes", maxnodes);
2215  if (!fPainter) return;
2217  Int_t level = fPainter->GetVisLevel();
2218  if (level != fVisLevel) fVisLevel = level;
2219 }
2220 
2221 ////////////////////////////////////////////////////////////////////////////////
2222 /// make top volume visible on screen
2223 
2225  GetGeomPainter();
2226  fPainter->SetTopVisible(vis);
2227 }
2228 
2229 ////////////////////////////////////////////////////////////////////////////////
2230 /// Assign a given node to be checked for overlaps. Any other overlaps will be ignored.
2231 
2233  GetGeomPainter()->SetCheckedNode(node);
2234 }
2235 
2236 ////////////////////////////////////////////////////////////////////////////////
2237 /// Set the number of points to be generated on the shape outline when checking
2238 /// for overlaps.
2239 
2241 {
2242  GetGeomPainter()->SetNmeshPoints(npoints);
2243 }
2244 
2245 ////////////////////////////////////////////////////////////////////////////////
2246 /// set drawing mode :
2247 /// - option=0 (default) all nodes drawn down to vislevel
2248 /// - option=1 leaves and nodes at vislevel drawn
2249 /// - option=2 path is drawn
2250 /// - option=4 visibility changed
2251 
2253  if ((option>=0) && (option<3)) fVisOption=option;
2254  if (fPainter) fPainter->SetVisOption(option);
2255 }
2256 
2257 ////////////////////////////////////////////////////////////////////////////////
2258 /// Set visualization option (leaves only OR all volumes)
2259 
2261 {
2262  if (flag) SetVisOption(1);
2263  else SetVisOption(0);
2264 }
2265 
2266 ////////////////////////////////////////////////////////////////////////////////
2267 /// Set density threshold. Volumes with densities lower than this become
2268 /// transparent.
2269 
2271 {
2272  fVisDensity = density;
2273  if (fPainter) fPainter->ModifiedPad();
2274 }
2275 
2276 ////////////////////////////////////////////////////////////////////////////////
2277 /// set default level down to which visualization is performed
2278 
2280  if (level>0) {
2281  fVisLevel = level;
2282  fMaxVisNodes = 0;
2283  if (fgVerboseLevel>0)
2284  Info("SetVisLevel","Automatic visible depth disabled");
2286  } else {
2287  SetMaxVisNodes();
2288  }
2289 }
2290 
2291 ////////////////////////////////////////////////////////////////////////////////
2292 /// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2293 
2295 {
2296  fOverlaps->Sort();
2297 }
2298 
2299 ////////////////////////////////////////////////////////////////////////////////
2300 /// Optimize voxelization type for all volumes. Save best choice in a macro.
2301 
2302 void TGeoManager::OptimizeVoxels(const char *filename)
2303 {
2304  if (!fTopNode) {
2305  Error("OptimizeVoxels","Geometry must be closed first");
2306  return;
2307  }
2308  std::ofstream out;
2309  TString fname = filename;
2310  if (fname.IsNull()) fname = "tgeovox.C";
2311  out.open(fname, std::ios::out);
2312  if (!out.good()) {
2313  Error("OptimizeVoxels", "cannot open file");
2314  return;
2315  }
2316  // write header
2317  TDatime t;
2318  TString sname(fname);
2319  sname.ReplaceAll(".C", "");
2320  out << sname.Data()<<"()"<<std::endl;
2321  out << "{" << std::endl;
2322  out << "//=== Macro generated by ROOT version "<< gROOT->GetVersion()<<" : "<<t.AsString()<<std::endl;
2323  out << "//=== Voxel optimization for " << GetTitle() << " geometry"<<std::endl;
2324  out << "//===== <run this macro JUST BEFORE closing the geometry>"<<std::endl;
2325  out << " TGeoVolume *vol = 0;"<<std::endl;
2326  out << " // parse all voxelized volumes"<<std::endl;
2327  TGeoVolume *vol = 0;
2328  Bool_t cyltype;
2329  TIter next(fVolumes);
2330  while ((vol=(TGeoVolume*)next())) {
2331  if (!vol->GetVoxels()) continue;
2332  out<<" vol = gGeoManager->GetVolume(\""<<vol->GetName()<<"\");"<<std::endl;
2333  cyltype = vol->OptimizeVoxels();
2334  if (cyltype) {
2335  out<<" vol->SetCylVoxels();"<<std::endl;
2336  } else {
2337  out<<" vol->SetCylVoxels(kFALSE);"<<std::endl;
2338  }
2339  }
2340  out << "}" << std::endl;
2341  out.close();
2342 }
2343 ////////////////////////////////////////////////////////////////////////////////
2344 /// Parse a string boolean expression and do a syntax check. Find top
2345 /// level boolean operator and returns its type. Fill the two
2346 /// substrings to which this operator applies. The returned integer is :
2347 /// - -1 : parse error
2348 /// - 0 : no boolean operator
2349 /// - 1 : union - represented as '+' in expression
2350 /// - 2 : difference (subtraction) - represented as '-' in expression
2351 /// - 3 : intersection - represented as '*' in expression.
2352 /// Parentheses should be used to avoid ambiguities. For instance :
2353 /// - A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2354 /// eliminate not needed parentheses
2355 
2356 Int_t TGeoManager::Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
2357 {
2358  TString startstr(expr);
2359  Int_t len = startstr.Length();
2360  Int_t i;
2361  TString e0 = "";
2362  expr3 = "";
2363  // eliminate blanks
2364  for (i=0; i< len; i++) {
2365  if (startstr(i)==' ') continue;
2366  e0 += startstr(i, 1);
2367  }
2368  Int_t level = 0;
2369  Int_t levmin = 999;
2370  Int_t boolop = 0;
2371  Int_t indop = 0;
2372  Int_t iloop = 1;
2373  Int_t lastop = 0;
2374  Int_t lastdp = 0;
2375  Int_t lastpp = 0;
2376  Bool_t foundmat = kFALSE;
2377  // check/eliminate parentheses
2378  while (iloop==1) {
2379  iloop = 0;
2380  lastop = 0;
2381  lastdp = 0;
2382  lastpp = 0;
2383  len = e0.Length();
2384  for (i=0; i<len; i++) {
2385  if (e0(i)=='(') {
2386  if (!level) iloop++;
2387  level++;
2388  continue;
2389  }
2390  if (e0(i)==')') {
2391  level--;
2392  if (level==0) lastpp=i;
2393  continue;
2394  }
2395  if ((e0(i)=='+') || (e0(i)=='-') || (e0(i)=='*')) {
2396  lastop = i;
2397  if (level<levmin) {
2398  levmin = level;
2399  indop = i;
2400  }
2401  continue;
2402  }
2403  if ((e0(i)==':') && (level==0)) {
2404  lastdp = i;
2405  continue;
2406  }
2407  }
2408  if (level!=0) {
2409  if (gGeoManager) gGeoManager->Error("Parse","parentheses does not match");
2410  return -1;
2411  }
2412  if (iloop==1 && (e0(0)=='(') && (e0(len-1)==')')) {
2413  // eliminate extra parentheses
2414  e0=e0(1, len-2);
2415  continue;
2416  }
2417  if (foundmat) break;
2418  if (((lastop==0) && (lastdp>0)) || ((lastpp>0) && (lastdp>lastpp) && (indop<lastpp))) {
2419  expr3 = e0(lastdp+1, len-lastdp);
2420  e0=e0(0, lastdp);
2421  foundmat = kTRUE;
2422  iloop = 1;
2423  continue;
2424  } else break;
2425  }
2426  // loop expression and search parentheses/operators
2427  levmin = 999;
2428  for (i=0; i<len; i++) {
2429  if (e0(i)=='(') {
2430  level++;
2431  continue;
2432  }
2433  if (e0(i)==')') {
2434  level--;
2435  continue;
2436  }
2437  // Take LAST operator at lowest level (revision 28/07/08)
2438  if (level<=levmin) {
2439  if (e0(i)=='+') {
2440  boolop = 1; // union
2441  levmin = level;
2442  indop = i;
2443  }
2444  if (e0(i)=='-') {
2445  boolop = 2; // difference
2446  levmin = level;
2447  indop = i;
2448  }
2449  if (e0(i)=='*') {
2450  boolop = 3; // intersection
2451  levmin = level;
2452  indop = i;
2453  }
2454  }
2455  }
2456  if (indop==0) {
2457  expr1=e0;
2458  return indop;
2459  }
2460  expr1 = e0(0, indop);
2461  expr2 = e0(indop+1, len-indop);
2462  return boolop;
2463 }
2464 
2465 
2466 ////////////////////////////////////////////////////////////////////////////////
2467 /// Save current attributes in a macro
2468 
2469 void TGeoManager::SaveAttributes(const char *filename)
2470 {
2471  if (!fTopNode) {
2472  Error("SaveAttributes","geometry must be closed first\n");
2473  return;
2474  }
2475  std::ofstream out;
2476  TString fname(filename);
2477  if (fname.IsNull()) fname = "tgeoatt.C";
2478  out.open(fname, std::ios::out);
2479  if (!out.good()) {
2480  Error("SaveAttributes", "cannot open file");
2481  return;
2482  }
2483  // write header
2484  TDatime t;
2485  TString sname(fname);
2486  sname.ReplaceAll(".C", "");
2487  out << sname.Data()<<"()"<<std::endl;
2488  out << "{" << std::endl;
2489  out << "//=== Macro generated by ROOT version "<< gROOT->GetVersion()<<" : "<<t.AsString()<<std::endl;
2490  out << "//=== Attributes for " << GetTitle() << " geometry"<<std::endl;
2491  out << "//===== <run this macro AFTER loading the geometry in memory>"<<std::endl;
2492  // save current top volume
2493  out << " TGeoVolume *top = gGeoManager->GetVolume(\""<<fTopVolume->GetName()<<"\");"<<std::endl;
2494  out << " TGeoVolume *vol = 0;"<<std::endl;
2495  out << " TGeoNode *node = 0;"<<std::endl;
2496  out << " // clear all volume attributes and get painter"<<std::endl;
2497  out << " gGeoManager->ClearAttributes();"<<std::endl;
2498  out << " gGeoManager->GetGeomPainter();"<<std::endl;
2499  out << " // set visualization modes and bomb factors"<<std::endl;
2500  out << " gGeoManager->SetVisOption("<<GetVisOption()<<");"<<std::endl;
2501  out << " gGeoManager->SetVisLevel("<<GetVisLevel()<<");"<<std::endl;
2502  out << " gGeoManager->SetExplodedView("<<GetBombMode()<<");"<<std::endl;
2503  Double_t bombx, bomby, bombz, bombr;
2504  GetBombFactors(bombx, bomby, bombz, bombr);
2505  out << " gGeoManager->SetBombFactors("<<bombx<<","<<bomby<<","<<bombz<<","<<bombr<<");"<<std::endl;
2506  out << " // iterate volumes container and set new attributes"<<std::endl;
2507 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2508  TGeoVolume *vol = 0;
2509  fTopNode->SaveAttributes(out);
2510 
2511  TIter next(fVolumes);
2512  while ((vol=(TGeoVolume*)next())) {
2513  vol->SetVisStreamed(kFALSE);
2514  }
2515  out << " // draw top volume with new settings"<<std::endl;
2516  out << " top->Draw();"<<std::endl;
2517  out << " gPad->x3d();"<<std::endl;
2518  out << "}" << std::endl;
2519  out.close();
2520 }
2521 
2522 ////////////////////////////////////////////////////////////////////////////////
2523 /// Returns the deepest node containing fPoint, which must be set a priori.
2524 
2525 TGeoNode *TGeoManager::SearchNode(Bool_t downwards, const TGeoNode *skipnode)
2526 {
2527  return GetCurrentNavigator()->SearchNode(downwards, skipnode);
2528 }
2529 
2530 ////////////////////////////////////////////////////////////////////////////////
2531 /// Cross next boundary and locate within current node
2532 /// The current point must be on the boundary of fCurrentNode.
2533 
2535 {
2536  return GetCurrentNavigator()->CrossBoundaryAndLocate(downwards, skipnode);
2537 }
2538 
2539 ////////////////////////////////////////////////////////////////////////////////
2540 /// Compute distance to next boundary within STEPMAX. If no boundary is found,
2541 /// propagate current point along current direction with fStep=STEPMAX. Otherwise
2542 /// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2543 /// node.
2544 
2546 {
2547  return GetCurrentNavigator()->FindNextBoundaryAndStep(stepmax, compsafe);
2548 }
2549 
2550 ////////////////////////////////////////////////////////////////////////////////
2551 /// Find distance to next boundary and store it in fStep. Returns node to which this
2552 /// boundary belongs. If PATH is specified, compute only distance to the node to which
2553 /// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2554 /// than this value. STEPMAX represent the step to be made imposed by other reasons than
2555 /// geometry (usually physics processes). Therefore in this case this method provides the
2556 /// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2557 /// fStep with a big number.
2558 /// In case frombdr=kTRUE, the isotropic safety is set to zero.
2559 ///
2560 /// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2561 /// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2562 /// they want this computed for the current point.
2563 
2564 TGeoNode *TGeoManager::FindNextBoundary(Double_t stepmax, const char *path, Bool_t frombdr)
2565 {
2566  // convert current point and direction to local reference
2567  return GetCurrentNavigator()->FindNextBoundary(stepmax,path, frombdr);
2568 }
2569 
2570 ////////////////////////////////////////////////////////////////////////////////
2571 /// Computes as fStep the distance to next daughter of the current volume.
2572 /// The point and direction must be converted in the coordinate system of the current volume.
2573 /// The proposed step limit is fStep.
2574 
2576 {
2577  return GetCurrentNavigator()->FindNextDaughterBoundary(point, dir, idaughter, compmatrix);
2578 }
2579 
2580 ////////////////////////////////////////////////////////////////////////////////
2581 /// Reset current state flags.
2582 
2584 {
2586 }
2587 
2588 ////////////////////////////////////////////////////////////////////////////////
2589 /// Returns deepest node containing current point.
2590 
2592 {
2593  return GetCurrentNavigator()->FindNode(safe_start);
2594 }
2595 
2596 ////////////////////////////////////////////////////////////////////////////////
2597 /// Returns deepest node containing current point.
2598 
2600 {
2601  return GetCurrentNavigator()->FindNode(x, y, z);
2602 }
2603 
2604 ////////////////////////////////////////////////////////////////////////////////
2605 /// Computes fast normal to next crossed boundary, assuming that the current point
2606 /// is close enough to the boundary. Works only after calling FindNextBoundary.
2607 
2609 {
2610  return GetCurrentNavigator()->FindNormalFast();
2611 }
2612 
2613 ////////////////////////////////////////////////////////////////////////////////
2614 /// Computes normal vector to the next surface that will be or was already
2615 /// crossed when propagating on a straight line from a given point/direction.
2616 /// Returns the normal vector cosines in the MASTER coordinate system. The dot
2617 /// product of the normal and the current direction is positive defined.
2618 
2620 {
2621  return GetCurrentNavigator()->FindNormal(forward);
2622 }
2623 
2624 ////////////////////////////////////////////////////////////////////////////////
2625 /// Checks if point (x,y,z) is still in the current node.
2626 
2628 {
2629  return GetCurrentNavigator()->IsSameLocation(x,y,z,change);
2630 }
2631 
2632 ////////////////////////////////////////////////////////////////////////////////
2633 /// Check if a new point with given coordinates is the same as the last located one.
2634 
2636 {
2637  return GetCurrentNavigator()->IsSamePoint(x,y,z);
2638 }
2639 
2640 ////////////////////////////////////////////////////////////////////////////////
2641 /// True if current node is in phi range
2642 
2644 {
2645  if (!fPhiCut) return kTRUE;
2646  const Double_t *origin;
2648  origin = ((TGeoBBox*)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2649  Double_t point[3];
2650  LocalToMaster(origin, &point[0]);
2651  Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
2652  if (phi<0) phi+=360.;
2653  if ((phi>=fPhimin) && (phi<=fPhimax)) return kFALSE;
2654  return kTRUE;
2655 }
2656 
2657 ////////////////////////////////////////////////////////////////////////////////
2658 /// Initialize current point and current direction vector (normalized)
2659 /// in MARS. Return corresponding node.
2660 
2662 {
2663  return GetCurrentNavigator()->InitTrack(point, dir);
2664 }
2665 
2666 ////////////////////////////////////////////////////////////////////////////////
2667 /// Initialize current point and current direction vector (normalized)
2668 /// in MARS. Return corresponding node.
2669 
2671 {
2672  return GetCurrentNavigator()->InitTrack(x,y,z,nx,ny,nz);
2673 }
2674 
2675 ////////////////////////////////////////////////////////////////////////////////
2676 /// Inspects path and all flags for the current state.
2677 
2679 {
2681 }
2682 
2683 ////////////////////////////////////////////////////////////////////////////////
2684 /// Get path to the current node in the form /node0/node1/...
2685 
2686 const char *TGeoManager::GetPath() const
2687 {
2688  return GetCurrentNavigator()->GetPath();
2689 }
2690 
2691 ////////////////////////////////////////////////////////////////////////////////
2692 /// Get total size of geometry in bytes.
2693 
2695 {
2696  Int_t count = 0;
2697  TIter next(fVolumes);
2698  TGeoVolume *vol;
2699  while ((vol=(TGeoVolume*)next())) count += vol->GetByteCount();
2700  TIter next1(fMatrices);
2701  TGeoMatrix *matrix;
2702  while ((matrix=(TGeoMatrix*)next1())) count += matrix->GetByteCount();
2703  TIter next2(fMaterials);
2704  TGeoMaterial *mat;
2705  while ((mat=(TGeoMaterial*)next2())) count += mat->GetByteCount();
2706  TIter next3(fMedia);
2707  TGeoMedium *med;
2708  while ((med=(TGeoMedium*)next3())) count += med->GetByteCount();
2709  if (fgVerboseLevel>0) Info("GetByteCount","Total size of logical tree : %i bytes", count);
2710  return count;
2711 }
2712 
2713 ////////////////////////////////////////////////////////////////////////////////
2714 /// Make a default painter if none present. Returns pointer to it.
2715 
2717 {
2718  if (!fPainter) {
2719  TPluginHandler *h;
2720  if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter"))) {
2721  if (h->LoadPlugin() == -1)
2722  return 0;
2723  fPainter = (TVirtualGeoPainter*)h->ExecPlugin(1,this);
2724  if (!fPainter) {
2725  Error("GetGeomPainter", "could not create painter");
2726  return 0;
2727  }
2728  }
2729  }
2730  return fPainter;
2731 }
2732 
2733 ////////////////////////////////////////////////////////////////////////////////
2734 /// Search for a named volume. All trailing blanks stripped.
2735 
2737 {
2738  TString sname = name;
2739  sname = sname.Strip();
2740  TGeoVolume *vol = (TGeoVolume*)fVolumes->FindObject(sname.Data());
2741  return vol;
2742 }
2743 
2744 ////////////////////////////////////////////////////////////////////////////////
2745 /// Fast search for a named volume. All trailing blanks stripped.
2746 
2748 {
2749  if (!fHashVolumes) {
2750  Int_t nvol = fVolumes->GetEntriesFast();
2751  Int_t ngvol = fGVolumes->GetEntriesFast();
2752  fHashVolumes = new THashList(nvol+1);
2753  fHashGVolumes = new THashList(ngvol+1);
2754  Int_t i;
2755  for (i=0; i<ngvol; i++) fHashGVolumes->AddLast(fGVolumes->At(i));
2756  for (i=0; i<nvol; i++) fHashVolumes->AddLast(fVolumes->At(i));
2757  }
2758  TString sname = name;
2759  sname = sname.Strip();
2760  THashList *list = fHashVolumes;
2761  if (multi) list = fHashGVolumes;
2762  TGeoVolume *vol = (TGeoVolume*)list->FindObject(sname.Data());
2763  return vol;
2764 }
2765 
2766 ////////////////////////////////////////////////////////////////////////////////
2767 /// Retrieve unique id for a volume name. Return -1 if name not found.
2768 
2769 Int_t TGeoManager::GetUID(const char *volname) const
2770 {
2771  TGeoManager *geom = (TGeoManager*)this;
2772  TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
2773  if (!vol) vol = geom->FindVolumeFast(volname, kTRUE);
2774  if (!vol) return -1;
2775  return vol->GetNumber();
2776 }
2777 
2778 ////////////////////////////////////////////////////////////////////////////////
2779 /// Find if a given material duplicates an existing one.
2780 
2782 {
2783  Int_t index = fMaterials->IndexOf(mat);
2784  if (index <= 0) return 0;
2785  TGeoMaterial *other;
2786  for (Int_t i=0; i<index; i++) {
2787  other = (TGeoMaterial*)fMaterials->At(i);
2788  if (other == mat) continue;
2789  if (other->IsEq(mat)) return other;
2790  }
2791  return 0;
2792 }
2793 
2794 ////////////////////////////////////////////////////////////////////////////////
2795 /// Search for a named material. All trailing blanks stripped.
2796 
2797 TGeoMaterial *TGeoManager::GetMaterial(const char *matname) const
2798 {
2799  TString sname = matname;
2800  sname = sname.Strip();
2801  TGeoMaterial *mat = (TGeoMaterial*)fMaterials->FindObject(sname.Data());
2802  return mat;
2803 }
2804 
2805 ////////////////////////////////////////////////////////////////////////////////
2806 /// Search for a named tracking medium. All trailing blanks stripped.
2807 
2808 TGeoMedium *TGeoManager::GetMedium(const char *medium) const
2809 {
2810  TString sname = medium;
2811  sname = sname.Strip();
2812  TGeoMedium *med = (TGeoMedium*)fMedia->FindObject(sname.Data());
2813  return med;
2814 }
2815 
2816 ////////////////////////////////////////////////////////////////////////////////
2817 /// Search for a tracking medium with a given ID.
2818 
2820 {
2821  TIter next(fMedia);
2822  TGeoMedium *med;
2823  while ((med=(TGeoMedium*)next())) {
2824  if (med->GetId()==numed) return med;
2825  }
2826  return 0;
2827 }
2828 
2829 ////////////////////////////////////////////////////////////////////////////////
2830 /// Return material at position id.
2831 
2833 {
2834  if (id<0 || id >= fMaterials->GetSize()) return 0;
2835  TGeoMaterial *mat = (TGeoMaterial*)fMaterials->At(id);
2836  return mat;
2837 }
2838 
2839 ////////////////////////////////////////////////////////////////////////////////
2840 /// Return index of named material.
2841 
2842 Int_t TGeoManager::GetMaterialIndex(const char *matname) const
2843 {
2844  TIter next(fMaterials);
2845  TGeoMaterial *mat;
2846  Int_t id = 0;
2847  TString sname = matname;
2848  sname = sname.Strip();
2849  while ((mat = (TGeoMaterial*)next())) {
2850  if (!strcmp(mat->GetName(),sname.Data()))
2851  return id;
2852  id++;
2853  }
2854  return -1; // fail
2855 }
2856 
2857 ////////////////////////////////////////////////////////////////////////////////
2858 /// Randomly shoot nrays and plot intersections with surfaces for current
2859 /// top node.
2860 
2861 void TGeoManager::RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol, Bool_t check_norm)
2862 {
2863  GetGeomPainter()->RandomRays(nrays, startx, starty, startz, target_vol, check_norm);
2864 }
2865 
2866 ////////////////////////////////////////////////////////////////////////////////
2867 /// Remove material at given index.
2868 
2870 {
2871  TObject *obj = fMaterials->At(index);
2872  if (obj) fMaterials->Remove(obj);
2873 }
2874 
2875 ////////////////////////////////////////////////////////////////////////////////
2876 /// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
2877 /// from geometry. Deletion has to be managed by users.
2878 
2880 {
2881  TIter next(fVolumes);
2882  TGeoVolume *vol;
2883  while ((vol=(TGeoVolume*)next())) vol->SetField(0);
2884 }
2885 
2886 ////////////////////////////////////////////////////////////////////////////////
2887 /// Change raytracing mode.
2888 
2890 {
2891  fRaytraceMode = mode;
2893 }
2894 
2895 ////////////////////////////////////////////////////////////////////////////////
2896 /// Restore the master volume of the geometry.
2897 
2899 {
2900  if (fTopVolume == fMasterVolume) return;
2902 }
2903 
2904 ////////////////////////////////////////////////////////////////////////////////
2905 /// Voxelize all non-divided volumes.
2906 
2908 {
2909  TGeoVolume *vol;
2910 // TGeoVoxelFinder *vox = 0;
2911  if (!fStreamVoxels && fgVerboseLevel>0) Info("Voxelize","Voxelizing...");
2912 // Int_t nentries = fVolumes->GetSize();
2913  TIter next(fVolumes);
2914  while ((vol = (TGeoVolume*)next())) {
2915  if (!fIsGeomReading) vol->SortNodes();
2916  if (!fStreamVoxels) {
2917  vol->Voxelize(option);
2918  }
2919  if (!fIsGeomReading) vol->FindOverlaps();
2920  }
2921 }
2922 
2923 ////////////////////////////////////////////////////////////////////////////////
2924 /// Send "Modified" signal to painter.
2925 
2927 {
2928  if (!fPainter) return;
2929  fPainter->ModifiedPad();
2930 }
2931 
2932 ////////////////////////////////////////////////////////////////////////////////
2933 /// Make an TGeoArb8 volume.
2934 
2936  Double_t dz, Double_t *vertices)
2937 {
2938  return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
2939 }
2940 
2941 ////////////////////////////////////////////////////////////////////////////////
2942 /// Make in one step a volume pointing to a box shape with given medium.
2943 
2945  Double_t dx, Double_t dy, Double_t dz)
2946 {
2947  return TGeoBuilder::Instance(this)->MakeBox(name, medium, dx, dy, dz);
2948 }
2949 
2950 ////////////////////////////////////////////////////////////////////////////////
2951 /// Make in one step a volume pointing to a parallelepiped shape with given medium.
2952 
2954  Double_t dx, Double_t dy, Double_t dz,
2955  Double_t alpha, Double_t theta, Double_t phi)
2956 {
2957  return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
2958 }
2959 
2960 ////////////////////////////////////////////////////////////////////////////////
2961 /// Make in one step a volume pointing to a sphere shape with given medium
2962 
2964  Double_t rmin, Double_t rmax, Double_t themin, Double_t themax,
2965  Double_t phimin, Double_t phimax)
2966 {
2967  return TGeoBuilder::Instance(this)->MakeSphere(name, medium, rmin, rmax, themin, themax, phimin, phimax);
2968 }
2969 
2970 ////////////////////////////////////////////////////////////////////////////////
2971 /// Make in one step a volume pointing to a torus shape with given medium.
2972 
2974  Double_t rmin, Double_t rmax, Double_t phi1, Double_t dphi)
2975 {
2976  return TGeoBuilder::Instance(this)->MakeTorus(name, medium, r, rmin, rmax, phi1, dphi);
2977 }
2978 
2979 ////////////////////////////////////////////////////////////////////////////////
2980 /// Make in one step a volume pointing to a tube shape with given medium.
2981 
2983  Double_t rmin, Double_t rmax, Double_t dz)
2984 {
2985  return TGeoBuilder::Instance(this)->MakeTube(name, medium, rmin, rmax, dz);
2986 }
2987 
2988 ////////////////////////////////////////////////////////////////////////////////
2989 /// Make in one step a volume pointing to a tube segment shape with given medium.
2990 /// The segment will be from phiStart to phiEnd, the angles are expressed in degree
2991 
2993  Double_t rmin, Double_t rmax, Double_t dz,
2994  Double_t phiStart, Double_t phiEnd)
2995 {
2996  return TGeoBuilder::Instance(this)->MakeTubs(name, medium, rmin, rmax, dz, phiStart, phiEnd);
2997 }
2998 
2999 ////////////////////////////////////////////////////////////////////////////////
3000 /// Make in one step a volume pointing to a tube shape with given medium
3001 
3003  Double_t a, Double_t b, Double_t dz)
3004 {
3005  return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
3006 }
3007 
3008 ////////////////////////////////////////////////////////////////////////////////
3009 /// Make in one step a volume pointing to a tube shape with given medium
3010 
3012  Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
3013 {
3014  return TGeoBuilder::Instance(this)->MakeHype(name, medium, rin, stin, rout, stout, dz);
3015 }
3016 
3017 ////////////////////////////////////////////////////////////////////////////////
3018 /// Make in one step a volume pointing to a tube shape with given medium
3019 
3021  Double_t rlo, Double_t rhi, Double_t dz)
3022 {
3023  return TGeoBuilder::Instance(this)->MakeParaboloid(name, medium, rlo, rhi, dz);
3024 }
3025 
3026 ////////////////////////////////////////////////////////////////////////////////
3027 /// Make in one step a volume pointing to a tube segment shape with given medium
3028 
3030  Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2,
3031  Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
3032 {
3033  return TGeoBuilder::Instance(this)->MakeCtub(name, medium, rmin, rmax, dz, phi1, phi2, lx, ly, lz, tx, ty, tz);
3034 }
3035 
3036 ////////////////////////////////////////////////////////////////////////////////
3037 /// Make in one step a volume pointing to a cone shape with given medium.
3038 
3040  Double_t dz, Double_t rmin1, Double_t rmax1,
3041  Double_t rmin2, Double_t rmax2)
3042 {
3043  return TGeoBuilder::Instance(this)->MakeCone(name, medium, dz, rmin1, rmax1, rmin2, rmax2);
3044 }
3045 
3046 ////////////////////////////////////////////////////////////////////////////////
3047 /// Make in one step a volume pointing to a cone segment shape with given medium
3048 
3050  Double_t dz, Double_t rmin1, Double_t rmax1,
3051  Double_t rmin2, Double_t rmax2,
3052  Double_t phi1, Double_t phi2)
3053 {
3054  return TGeoBuilder::Instance(this)->MakeCons(name, medium, dz, rmin1, rmax1, rmin2, rmax2, phi1, phi2);
3055 }
3056 
3057 ////////////////////////////////////////////////////////////////////////////////
3058 /// Make in one step a volume pointing to a polycone shape with given medium.
3059 
3061  Double_t phi, Double_t dphi, Int_t nz)
3062 {
3063  return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3064 }
3065 
3066 ////////////////////////////////////////////////////////////////////////////////
3067 /// Make in one step a volume pointing to a polygone shape with given medium.
3068 
3070  Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
3071 {
3072  return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3073 }
3074 
3075 ////////////////////////////////////////////////////////////////////////////////
3076 /// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3077 
3079  Double_t dx1, Double_t dx2, Double_t dy, Double_t dz)
3080 {
3081  return TGeoBuilder::Instance(this)->MakeTrd1(name, medium, dx1, dx2, dy, dz);
3082 }
3083 
3084 ////////////////////////////////////////////////////////////////////////////////
3085 /// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3086 
3088  Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2,
3089  Double_t dz)
3090 {
3091  return TGeoBuilder::Instance(this)->MakeTrd2(name, medium, dx1, dx2, dy1, dy2, dz);
3092 }
3093 
3094 ////////////////////////////////////////////////////////////////////////////////
3095 /// Make in one step a volume pointing to a trapezoid shape with given medium.
3096 
3098  Double_t dz, Double_t theta, Double_t phi, Double_t h1,
3099  Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
3100  Double_t tl2, Double_t alpha2)
3101 {
3102  return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2, alpha2);
3103 }
3104 
3105 ////////////////////////////////////////////////////////////////////////////////
3106 /// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3107 
3109  Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1,
3110  Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
3111  Double_t tl2, Double_t alpha2)
3112 {
3113  return TGeoBuilder::Instance(this)->MakeGtra(name, medium, dz, theta, phi, twist, h1, bl1, tl1, alpha1, h2, bl2, tl2, alpha2);
3114 }
3115 
3116 ////////////////////////////////////////////////////////////////////////////////
3117 /// Make a TGeoXtru-shaped volume with nz planes
3118 
3120 {
3121  return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3122 }
3123 
3124 ////////////////////////////////////////////////////////////////////////////////
3125 /// Creates an alignable object with unique name corresponding to a path
3126 /// and adds it to the list of alignables. An optional unique ID can be
3127 /// provided, in which case PN entries can be searched fast by uid.
3128 
3129 TGeoPNEntry *TGeoManager::SetAlignableEntry(const char *unique_name, const char *path,
3130  Int_t uid)
3131 {
3132  if (!CheckPath(path)) return NULL;
3133  if (!fHashPNE) fHashPNE = new THashList(256,3);
3134  if (!fArrayPNE) fArrayPNE = new TObjArray(256);
3135  TGeoPNEntry *entry = GetAlignableEntry(unique_name);
3136  if (entry) {
3137  Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3138  return 0;
3139  }
3140  entry = new TGeoPNEntry(unique_name, path);
3141  Int_t ientry = fHashPNE->GetSize();
3142  fHashPNE->Add(entry);
3143  fArrayPNE->AddAtAndExpand(entry, ientry);
3144  if (uid>=0) {
3145  Bool_t added = InsertPNEId(uid, ientry);
3146  if (!added) Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3147  }
3148  return entry;
3149 }
3150 
3151 ////////////////////////////////////////////////////////////////////////////////
3152 /// Retrieves an existing alignable object.
3153 
3155 {
3156  if (!fHashPNE) return 0;
3157  return (TGeoPNEntry*)fHashPNE->FindObject(name);
3158 }
3159 
3160 ////////////////////////////////////////////////////////////////////////////////
3161 /// Retrieves an existing alignable object at a given index.
3162 
3164 {
3165  if (!fArrayPNE && !InitArrayPNE()) return 0;
3166  return (TGeoPNEntry*)fArrayPNE->At(index);
3167 }
3168 
3169 ////////////////////////////////////////////////////////////////////////////////
3170 /// Retrieves an existing alignable object having a preset UID.
3171 
3173 {
3174  if (!fNPNEId || (!fArrayPNE && !InitArrayPNE())) return NULL;
3175  Int_t index = TMath::BinarySearch(fNPNEId, fKeyPNEId, uid);
3176  if (index<0 || fKeyPNEId[index]!=uid) return NULL;
3177  return (TGeoPNEntry*)fArrayPNE->At(fValuePNEId[index]);
3178 }
3179 
3180 ////////////////////////////////////////////////////////////////////////////////
3181 /// Retrieves number of PN entries with or without UID.
3182 
3184 {
3185  if (!fHashPNE) return 0;
3186  if (with_uid) return fNPNEId;
3187  return fHashPNE->GetSize();
3188 }
3189 
3190 ////////////////////////////////////////////////////////////////////////////////
3191 /// Insert a PN entry in the sorted array of indexes.
3192 
3194 {
3195  if (!fSizePNEId) {
3196  // Create the arrays.
3197  fSizePNEId = 128;
3198  fKeyPNEId = new Int_t[fSizePNEId];
3199  memset(fKeyPNEId, 0, fSizePNEId*sizeof(Int_t));
3200  fValuePNEId = new Int_t[fSizePNEId];
3201  memset(fValuePNEId, 0, fSizePNEId*sizeof(Int_t));
3202  fKeyPNEId[fNPNEId] = uid;
3203  fValuePNEId[fNPNEId++] = ientry;
3204  return kTRUE;
3205  }
3206  // Search id in the existing array and return false if it already exists.
3207  Int_t index = TMath::BinarySearch(fNPNEId, fKeyPNEId, uid);
3208  if (index>0 && fKeyPNEId[index]==uid) return kFALSE;
3209  // Resize the arrays and insert the value
3210  Bool_t resize = (fNPNEId==fSizePNEId)?kTRUE:kFALSE;
3211  if (resize) {
3212  // Double the size of the array
3213  fSizePNEId *= 2;
3214  // Create new arrays of keys and values
3215  Int_t *keys = new Int_t[fSizePNEId];
3216  memset(keys, 0, fSizePNEId*sizeof(Int_t));
3217  Int_t *values = new Int_t[fSizePNEId];
3218  memset(values, 0, fSizePNEId*sizeof(Int_t));
3219  // Copy all keys<uid in the new keys array (0 to index)
3220  memcpy(keys, fKeyPNEId, (index+1)*sizeof(Int_t));
3221  memcpy(values, fValuePNEId, (index+1)*sizeof(Int_t));
3222  // Insert current key at index+1
3223  keys[index+1] = uid;
3224  values[index+1] = ientry;
3225  // Copy all remaining keys from the old to new array
3226  memcpy(&keys[index+2], &fKeyPNEId[index+1], (fNPNEId-index-1)*sizeof(Int_t));
3227  memcpy(&values[index+2], &fValuePNEId[index+1], (fNPNEId-index-1)*sizeof(Int_t));
3228  delete [] fKeyPNEId;
3229  fKeyPNEId = keys;
3230  delete [] fValuePNEId;
3231  fValuePNEId = values;
3232  fNPNEId++;
3233  return kTRUE;
3234  }
3235  // Insert the value in the existing arrays
3236  Int_t i;
3237  for (i=fNPNEId-1; i>index; i--) {
3238  fKeyPNEId[i+1] = fKeyPNEId[i];
3239  fValuePNEId[i+1] = fValuePNEId[i];
3240  }
3241  fKeyPNEId[index+1] = uid;
3242  fValuePNEId[index+1] = ientry;
3243  fNPNEId++;
3244  return kTRUE;
3245 }
3246 
3247 ////////////////////////////////////////////////////////////////////////////////
3248 /// Make a physical node from the path pointed by an alignable object with a given name.
3249 
3251 {
3252  TGeoPNEntry *entry = GetAlignableEntry(name);
3253  if (!entry) {
3254  Error("MakeAlignablePN","No alignable object named %s found !", name);
3255  return 0;
3256  }
3257  return MakeAlignablePN(entry);
3258 }
3259 
3260 ////////////////////////////////////////////////////////////////////////////////
3261 /// Make a physical node from the path pointed by a given alignable object.
3262 
3264 {
3265  if (!entry) {
3266  Error("MakeAlignablePN","No alignable object specified !");
3267  return 0;
3268  }
3269  const char *path = entry->GetTitle();
3270  if (!cd(path)) {
3271  Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s",
3272  entry->GetName(), path);
3273  return 0;
3274  }
3275  TGeoPhysicalNode *node = MakePhysicalNode(path);
3276  entry->SetPhysicalNode(node);
3277  return node;
3278 }
3279 
3280 ////////////////////////////////////////////////////////////////////////////////
3281 /// Makes a physical node corresponding to a path. If PATH is not specified,
3282 /// makes physical node matching current modeller state.
3283 
3285 {
3286  TGeoPhysicalNode *node;
3287  if (path) {
3288  if (!CheckPath(path)) {
3289  Error("MakePhysicalNode", "path: %s not valid", path);
3290  return NULL;
3291  }
3292  node = new TGeoPhysicalNode(path);
3293  } else {
3294  node = new TGeoPhysicalNode(GetPath());
3295  }
3296  fPhysicalNodes->Add(node);
3297  return node;
3298 }
3299 
3300 ////////////////////////////////////////////////////////////////////////////////
3301 /// Refresh physical nodes to reflect the actual geometry paths after alignment
3302 /// was applied. Optionally locks physical nodes (default).
3303 
3305 {
3306  TIter next(gGeoManager->GetListOfPhysicalNodes());
3307  TGeoPhysicalNode *pn;
3308  while ((pn=(TGeoPhysicalNode*)next())) pn->Refresh();
3310  if (lock) LockGeometry();
3311 }
3312 
3313 ////////////////////////////////////////////////////////////////////////////////
3314 /// Clear the current list of physical nodes, so that we can start over with a new list.
3315 /// If MUSTDELETE is true, delete previous nodes.
3316 
3318 {
3319  if (mustdelete) fPhysicalNodes->Delete();
3320  else fPhysicalNodes->Clear();
3321 }
3322 
3323 ////////////////////////////////////////////////////////////////////////////////
3324 /// Make an assembly of volumes.
3325 
3327 {
3328  return TGeoBuilder::Instance(this)->MakeVolumeAssembly(name);
3329 }
3330 
3331 ////////////////////////////////////////////////////////////////////////////////
3332 /// Make a TGeoVolumeMulti handling a list of volumes.
3333 
3335 {
3336  return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3337 }
3338 
3339 ////////////////////////////////////////////////////////////////////////////////
3340 /// Set type of exploding view (see TGeoPainter::SetExplodedView())
3341 
3343 {
3344  if ((ibomb>=0) && (ibomb<4)) fExplodedView = ibomb;
3345  if (fPainter) fPainter->SetExplodedView(ibomb);
3346 }
3347 
3348 ////////////////////////////////////////////////////////////////////////////////
3349 /// Set cut phi range
3350 
3352 {
3353  if ((phimin==0) && (phimax==360)) {
3354  fPhiCut = kFALSE;
3355  return;
3356  }
3357  fPhiCut = kTRUE;
3358  fPhimin = phimin;
3359  fPhimax = phimax;
3360 }
3361 
3362 ////////////////////////////////////////////////////////////////////////////////
3363 /// Set number of segments for approximating circles in drawing.
3364 
3366 {
3367  if (fNsegments==nseg) return;
3368  if (nseg>2) fNsegments = nseg;
3369  if (fPainter) fPainter->SetNsegments(nseg);
3370 }
3371 
3372 ////////////////////////////////////////////////////////////////////////////////
3373 /// Get number of segments approximating circles
3374 
3376 {
3377  return fNsegments;
3378 }
3379 
3380 ////////////////////////////////////////////////////////////////////////////////
3381 /// Now just a shortcut for GetElementTable.
3382 
3384 {
3385  GetElementTable();
3387 }
3388 
3389 ////////////////////////////////////////////////////////////////////////////////
3390 /// Returns material table. Creates it if not existing.
3391 
3393 {
3394  if (!fElementTable) fElementTable = new TGeoElementTable(200);
3395  return fElementTable;
3396 }
3397 
3398 ////////////////////////////////////////////////////////////////////////////////
3399 /// Make a rectilinear step of length fStep from current point (fPoint) on current
3400 /// direction (fDirection). If the step is imposed by geometry, is_geom flag
3401 /// must be true (default). The cross flag specifies if the boundary should be
3402 /// crossed in case of a geometry step (default true). Returns new node after step.
3403 /// Set also on boundary condition.
3404 
3406 {
3407  return GetCurrentNavigator()->Step(is_geom, cross);
3408 }
3409 
3410 ////////////////////////////////////////////////////////////////////////////////
3411 /// shoot npoints randomly in a box of 1E-5 around current point.
3412 /// return minimum distance to points outside
3413 
3415  const char* g3path)
3416 {
3417  return GetGeomPainter()->SamplePoints(npoints, dist, epsil, g3path);
3418 }
3419 
3420 ////////////////////////////////////////////////////////////////////////////////
3421 /// Set the top volume and corresponding node as starting point of the geometry.
3422 
3424 {
3425  if (fTopVolume==vol) return;
3426 
3427  TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3428  TIter next(brlist);
3429  TBrowser *browser = 0;
3430 
3431  if (fTopVolume) fTopVolume->SetTitle("");
3432  fTopVolume = vol;
3433  vol->SetTitle("Top volume");
3434  if (fTopNode) {
3435  TGeoNode *topn = fTopNode;
3436  fTopNode = 0;
3437  while ((browser=(TBrowser*)next())) browser->RecursiveRemove(topn);
3438  delete topn;
3439  } else {
3440  fMasterVolume = vol;
3441  fMasterVolume->Grab();
3443  if (fgVerboseLevel>0) Info("SetTopVolume","Top volume is %s. Master volume is %s", fTopVolume->GetName(),
3444  fMasterVolume->GetName());
3445  }
3446 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3447 // fCurrentMatrix->Print();
3448  fTopNode = new TGeoNodeMatrix(vol, gGeoIdentity);
3449  fTopNode->SetName(TString::Format("%s_1",vol->GetName()));
3450  fTopNode->SetNumber(1);
3451  fTopNode->SetTitle("Top logical node");
3452  fNodes->AddAt(fTopNode, 0);
3453  if (!GetCurrentNavigator()) {
3455  return;
3456  }
3457  Int_t nnavigators = 0;
3459  if (!arr) return;
3460  nnavigators = arr->GetEntriesFast();
3461  for (Int_t i=0; i<nnavigators; i++) {
3462  TGeoNavigator *nav = (TGeoNavigator*)arr->At(i);
3463  nav->ResetAll();
3464  if (fClosed) nav->GetCache()->BuildInfoBranch();
3465  }
3466 }
3467 
3468 ////////////////////////////////////////////////////////////////////////////////
3469 /// Define different tracking media.
3470 
3472 {
3473 /*
3474  Int_t nmat = fMaterials->GetSize();
3475  if (!nmat) {printf(" No materials !\n"); return;}
3476  Int_t *media = new Int_t[nmat];
3477  memset(media, 0, nmat*sizeof(Int_t));
3478  Int_t imedia = 1;
3479  TGeoMaterial *mat, *matref;
3480  mat = (TGeoMaterial*)fMaterials->At(0);
3481  if (mat->GetMedia()) {
3482  for (Int_t i=0; i<nmat; i++) {
3483  mat = (TGeoMaterial*)fMaterials->At(i);
3484  mat->Print();
3485  }
3486  return;
3487  }
3488  mat->SetMedia(imedia);
3489  media[0] = imedia++;
3490  mat->Print();
3491  for (Int_t i=0; i<nmat; i++) {
3492  mat = (TGeoMaterial*)fMaterials->At(i);
3493  for (Int_t j=0; j<i; j++) {
3494  matref = (TGeoMaterial*)fMaterials->At(j);
3495  if (mat->IsEq(matref)) {
3496  mat->SetMedia(media[j]);
3497  break;
3498  }
3499  if (j==(i-1)) {
3500  // different material
3501  mat->SetMedia(imedia);
3502  media[i] = imedia++;
3503  mat->Print();
3504  }
3505  }
3506  }
3507 */
3508 }
3509 
3510 ////////////////////////////////////////////////////////////////////////////////
3511 /// Check pushes and pulls needed to cross the next boundary with respect to the
3512 /// position given by FindNextBoundary. If radius is not mentioned the full bounding
3513 /// box will be sampled.
3514 
3516 {
3517  GetGeomPainter()->CheckBoundaryErrors(ntracks, radius);
3518 }
3519 
3520 ////////////////////////////////////////////////////////////////////////////////
3521 /// Check the boundary errors reference file created by CheckBoundaryErrors method.
3522 /// The shape for which the crossing failed is drawn with the starting point in red
3523 /// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3524 
3526 {
3528 }
3529 
3530 ////////////////////////////////////////////////////////////////////////////////
3531 /// Classify a given point. See TGeoChecker::CheckPoint().
3532 
3534 {
3535  GetGeomPainter()->CheckPoint(x,y,z,option);
3536 }
3537 
3538 ////////////////////////////////////////////////////////////////////////////////
3539 /// Test for shape navigation methods. Summary for test numbers:
3540 /// - 1: DistFromInside/Outside. Sample points inside the shape. Generate
3541 /// directions randomly in cos(theta). Compute DistFromInside and move the
3542 /// point with bigger distance. Compute DistFromOutside back from new point.
3543 /// Plot d-(d1+d2)
3544 ///
3545 
3546 void TGeoManager::CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)
3547 {
3548  GetGeomPainter()->CheckShape(shape, testNo, nsamples, option);
3549 }
3550 
3551 ////////////////////////////////////////////////////////////////////////////////
3552 /// Geometry checking.
3553 /// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3554 /// - if option contains 'b': Optional boundary crossing check + timing per volume.
3555 ///
3556 /// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3557 /// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3558 /// be called for the suspicious volumes.
3559 ///
3560 /// STAGE 2: normal overlap checking using the shapes mesh - fills the list of
3561 /// overlaps.
3562 ///
3563 /// STAGE 3: shooting NRAYS rays from VERTEX and counting the total number of
3564 /// crossings per volume (rays propagated from boundary to boundary until
3565 /// geometry exit). Timing computed and results stored in a histo.
3566 ///
3567 /// STAGE 4: shooting 1 mil. random rays inside EACH volume and calling
3568 /// FindNextBoundary() + Safety() for each call. The timing is normalized by the
3569 /// number of crossings computed at stage 2 and presented as percentage.
3570 /// One can get a picture on which are the most "burned" volumes during
3571 /// transportation from geometry point of view. Another plot of the timing per
3572 /// volume vs. number of daughters is produced.
3573 
3575 {
3576  TString opt(option);
3577  opt.ToLower();
3578  if (!opt.Length()) {
3579  Error("CheckGeometryFull","The option string must contain a letter. See method documentation.");
3580  return;
3581  }
3582  Bool_t checkoverlaps = opt.Contains("o");
3583  Bool_t checkcrossings = opt.Contains("b");
3584  Double_t vertex[3];
3585  vertex[0] = vx;
3586  vertex[1] = vy;
3587  vertex[2] = vz;
3588  GetGeomPainter()->CheckGeometryFull(checkoverlaps,checkcrossings,ntracks,vertex);
3589 }
3590 
3591 ////////////////////////////////////////////////////////////////////////////////
3592 /// Perform last checks on the geometry
3593 
3595 {
3596  if (fgVerboseLevel>0) Info("CheckGeometry","Fixing runtime shapes...");
3597  TIter next(fShapes);
3598  TIter nextv(fVolumes);
3599  TGeoShape *shape;
3600  TGeoVolume *vol;
3601  Bool_t has_runtime = kFALSE;
3602  while ((shape = (TGeoShape*)next())) {
3603  if (shape->IsRunTimeShape()) {
3604  has_runtime = kTRUE;
3605  }
3606  if (fIsGeomReading) shape->AfterStreamer();
3608  if (!shape->TestShapeBit(TGeoShape::kGeoClosedShape)) shape->ComputeBBox();
3609  }
3610  if (has_runtime) fTopNode->CheckShapes();
3611  else if (fgVerboseLevel>0) Info("CheckGeometry","...Nothing to fix");
3612  // Compute bounding box for assemblies
3614  while ((vol = (TGeoVolume*)nextv())) {
3615  if (vol->IsAssembly()) vol->GetShape()->ComputeBBox();
3616  else if (vol->GetMedium() == dummy) {
3617  Warning("CheckGeometry", "Volume \"%s\" has no medium: assigned dummy medium and material", vol->GetName());
3618  vol->SetMedium(dummy);
3619  }
3620  }
3621 }
3622 
3623 ////////////////////////////////////////////////////////////////////////////////
3624 /// Check all geometry for illegal overlaps within a limit OVLP.
3625 
3627 {
3628  if (!fTopNode) {
3629  Error("CheckOverlaps","Top node not set");
3630  return;
3631  }
3632  fTopNode->CheckOverlaps(ovlp,option);
3633 }
3634 
3635 ////////////////////////////////////////////////////////////////////////////////
3636 /// Prints the current list of overlaps.
3637 
3639 {
3640  if (!fOverlaps) return;
3641  Int_t novlp = fOverlaps->GetEntriesFast();
3642  if (!novlp) return;
3643  TGeoManager *geom = (TGeoManager*)this;
3644  geom->GetGeomPainter()->PrintOverlaps();
3645 }
3646 
3647 ////////////////////////////////////////////////////////////////////////////////
3648 /// Estimate weight of volume VOL with a precision SIGMA(W)/W better than PRECISION.
3649 /// Option can be "v" - verbose (default)
3650 
3652 {
3653  GetGeomPainter();
3654  TString opt(option);
3655  opt.ToLower();
3656  Double_t weight;
3657  TGeoVolume *volume = fTopVolume;
3658  if (opt.Contains("v")) {
3659  if (opt.Contains("a")) {
3660  if (fgVerboseLevel>0) Info("Weight", "Computing analytically weight of %s", volume->GetName());
3661  weight = volume->WeightA();
3662  if (fgVerboseLevel>0) Info("Weight", "Computed weight: %f [kg]\n", weight);
3663  return weight;
3664  }
3665  if (fgVerboseLevel>0) {
3666  Info("Weight", "Estimating weight of %s with %g %% precision", fTopVolume->GetName(), 100.*precision);
3667  printf(" event weight err\n");
3668  printf("========================================\n");
3669  }
3670  }
3671  weight = fPainter->Weight(precision, option);
3672  return weight;
3673 }
3674 
3675 ////////////////////////////////////////////////////////////////////////////////
3676 /// computes the total size in bytes of the branch starting with node.
3677 /// The option can specify if all the branch has to be parsed or only the node
3678 
3679 ULong_t TGeoManager::SizeOf(const TGeoNode * /*node*/, Option_t * /*option*/)
3680 {
3681  return 0;
3682 }
3683 
3684 ////////////////////////////////////////////////////////////////////////////////
3685 /// Stream an object of class TGeoManager.
3686 
3687 void TGeoManager::Streamer(TBuffer &R__b)
3688 {
3689  if (R__b.IsReading()) {
3690  R__b.ReadClassBuffer(TGeoManager::Class(), this);
3692  CloseGeometry();
3695  } else {
3696  R__b.WriteClassBuffer(TGeoManager::Class(), this);
3697  }
3698 }
3699 
3700 ////////////////////////////////////////////////////////////////////////////////
3701 /// Execute mouse actions on this manager.
3702 
3704 {
3705  if (!fPainter) return;
3706  fPainter->ExecuteManagerEvent(this, event, px, py);
3707 }
3708 
3709 ////////////////////////////////////////////////////////////////////////////////
3710 /// Export this geometry to a file
3711 ///
3712 /// - Case 1: root file or root/xml file
3713 /// if filename end with ".root". The key will be named name
3714 /// By default the geometry is saved without the voxelisation info.
3715 /// Use option 'v" to save the voxelisation info.
3716 /// if filename end with ".xml" a root/xml file is produced.
3717 ///
3718 /// - Case 2: C++ script
3719 /// if filename end with ".C"
3720 ///
3721 /// - Case 3: gdml file
3722 /// if filename end with ".gdml"
3723 /// NOTE that to use this option, the PYTHONPATH must be defined like
3724 /// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/geom/gdml
3725 ///
3726 
3727 Int_t TGeoManager::Export(const char *filename, const char *name, Option_t *option)
3728 {
3729  TString sfile(filename);
3730  if (sfile.Contains(".C")) {
3731  //Save geometry as a C++ script
3732  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as C++ code", GetName(), GetTitle());
3733  fTopVolume->SaveAs(filename);
3734  return 1;
3735  }
3736  if (sfile.Contains(".gdml")) {
3737  //Save geometry as a gdml file
3738  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as gdml code", GetName(), GetTitle());
3739  //C++ version
3740  TString cmd ;
3741  cmd = TString::Format("TGDMLWrite::StartGDMLWriting(gGeoManager,\"%s\",\"%s\")", filename, option);
3742  gROOT->ProcessLineFast(cmd);
3743  return 1;
3744  }
3745  if (sfile.Contains(".root") || sfile.Contains(".xml")) {
3746  //Save geometry as a root file
3747  TFile *f = TFile::Open(filename,"recreate");
3748  if (!f || f->IsZombie()) {
3749  Error("Export","Cannot open file");
3750  return 0;
3751  }
3752  TString keyname = name;
3753  if (keyname.IsNull()) keyname = GetName();
3754  TString opt = option;
3755  opt.ToLower();
3756  if (opt.Contains("v")) {
3757  fStreamVoxels = kTRUE;
3758  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as root file. Optimizations streamed.", GetName(), GetTitle());
3759  } else {
3761  if (fgVerboseLevel>0) Info("Export","Exporting %s %s as root file. Optimizations not streamed.", GetName(), GetTitle());
3762  }
3763 
3764  const char *precision_dbl = TBufferText::GetDoubleFormat();
3765  const char *precision_flt = TBufferText::GetFloatFormat();
3766  TString new_format_dbl = TString::Format("%%.%dg", TGeoManager::GetExportPrecision());
3767  if (sfile.Contains(".xml")) {
3768  TBufferText::SetDoubleFormat(new_format_dbl.Data());
3769  TBufferText::SetFloatFormat(new_format_dbl.Data());
3770  }
3771  Int_t nbytes = Write(keyname);
3772  if (sfile.Contains(".xml")) {
3773  TBufferText::SetFloatFormat(precision_dbl);
3774  TBufferText::SetDoubleFormat(precision_flt);
3775  }
3776 
3778  delete f;
3779  return nbytes;
3780  }
3781  return 0;
3782 }
3783 
3784 ////////////////////////////////////////////////////////////////////////////////
3785 /// Lock current geometry so that no other geometry can be imported.
3786 
3788 {
3789  fgLock = kTRUE;
3790 }
3791 
3792 ////////////////////////////////////////////////////////////////////////////////
3793 /// Unlock current geometry.
3794 
3796 {
3797  fgLock = kFALSE;
3798 }
3799 
3800 ////////////////////////////////////////////////////////////////////////////////
3801 /// Check lock state.
3802 
3804 {
3805  return fgLock;
3806 }
3807 
3808 ////////////////////////////////////////////////////////////////////////////////
3809 /// Set verbosity level (static function).
3810 /// - 0 - suppress messages related to geom-painter visibility level
3811 /// - 1 - default value
3812 
3814 {
3815  return fgVerboseLevel;
3816 }
3817 
3818 ////////////////////////////////////////////////////////////////////////////////
3819 /// Return current verbosity level (static function).
3820 
3822 {
3823  fgVerboseLevel = vl;
3824 }
3825 
3826 ////////////////////////////////////////////////////////////////////////////////
3827 ///static function
3828 ///Import a geometry from a gdml or ROOT file
3829 ///
3830 /// - Case 1: gdml
3831 /// if filename ends with ".gdml" the foreign geometry described with gdml
3832 /// is imported executing some python scripts in $ROOTSYS/gdml.
3833 /// NOTE that to use this option, the PYTHONPATH must be defined like
3834 /// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
3835 ///
3836 /// - Case 2: root file (.root) or root/xml file (.xml)
3837 /// Import in memory from filename the geometry with key=name.
3838 /// if name="" (default), the first TGeoManager object in the file is returned.
3839 ///
3840 /// Note that this function deletes the current gGeoManager (if one)
3841 /// before importing the new object.
3842 
3843 TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
3844 {
3845  if (fgLock) {
3846  ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
3847  return NULL;
3848  }
3849  if (!filename) return 0;
3850  if (fgVerboseLevel>0) ::Info("TGeoManager::Import","Reading geometry from file: %s",filename);
3851 
3852  if (gGeoManager) delete gGeoManager;
3853  gGeoManager = 0;
3854 
3855  if (strstr(filename,".gdml")) {
3856  // import from a gdml file
3857  new TGeoManager("GDMLImport", "Geometry imported from GDML");
3858  TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
3859  TGeoVolume* world = (TGeoVolume*)gROOT->ProcessLineFast(cmd);
3860 
3861  if(world == 0) {
3862  ::Error("TGeoManager::Import", "Cannot open file");
3863  }
3864  else {
3865  gGeoManager->SetTopVolume(world);
3866  gGeoManager->CloseGeometry();
3867  gGeoManager->DefaultColors();
3868  }
3869  } else {
3870  // import from a root file
3871  TDirectory::TContext ctxt;
3872  // in case a web file is specified, use the cacheread option to cache
3873  // this file in the cache directory
3874  TFile *f = 0;
3875  if (strstr(filename,"http")) f = TFile::Open(filename,"CACHEREAD");
3876  else f = TFile::Open(filename);
3877  if (!f || f->IsZombie()) {
3878  ::Error("TGeoManager::Import", "Cannot open file");
3879  return 0;
3880  }
3881  if (name && strlen(name) > 0) {
3882  gGeoManager = (TGeoManager*)f->Get(name);
3883  } else {
3884  TIter next(f->GetListOfKeys());
3885  TKey *key;
3886  while ((key = (TKey*)next())) {
3887  if (strcmp(key->GetClassName(),"TGeoManager") != 0) continue;
3888  gGeoManager = (TGeoManager*)key->ReadObj();
3889  break;
3890  }
3891  }
3892  delete f;
3893  }
3894  if (!gGeoManager) return 0;
3895  if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager)) gROOT->GetListOfGeometries()->Add(gGeoManager);
3896  if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager)) gROOT->GetListOfBrowsables()->Add(gGeoManager);
3897  gGeoManager->UpdateElements();
3898  return gGeoManager;
3899 }
3900 
3901 ////////////////////////////////////////////////////////////////////////////////
3902 /// Update element flags when geometry is loaded from a file.
3903 
3905 {
3906  if (!fElementTable) return;
3907  TIter next(fMaterials);
3908  TGeoMaterial *mat;
3909  TGeoMixture *mix;
3910  TGeoElement *elem, *elem_table;
3911  Int_t i, nelem;
3912  while ((mat=(TGeoMaterial*)next())) {
3913  if (mat->IsMixture()) {
3914  mix = (TGeoMixture*)mat;
3915  nelem = mix->GetNelements();
3916  for (i=0; i<nelem; i++) {
3917  elem = mix->GetElement(i);
3918  if (!elem) continue;
3919  elem_table = fElementTable->GetElement(elem->Z());
3920  if (!elem_table) continue;
3921  if (elem != elem_table) {
3922  elem_table->SetDefined(elem->IsDefined());
3923  elem_table->SetUsed(elem->IsUsed());
3924  } else {
3925  elem_table->SetDefined();
3926  }
3927  }
3928  } else {
3929  elem = mat->GetElement();
3930  if (!elem) continue;
3931  elem_table = fElementTable->GetElement(elem->Z());
3932  if (!elem_table) continue;
3933  if (elem != elem_table) {
3934  elem_table->SetDefined(elem->IsDefined());
3935  elem_table->SetUsed(elem->IsUsed());
3936  } else {
3937  elem_table->SetUsed();
3938  }
3939  }
3940  }
3941 }
3942 
3943 ////////////////////////////////////////////////////////////////////////////////
3944 /// Initialize PNE array for fast access via index and unique-id.
3945 
3947 {
3948  if (fHashPNE) {
3949  fArrayPNE = new TObjArray(fHashPNE->GetSize());
3950  TIter next(fHashPNE);
3951  TObject *obj;
3952  while ((obj = next())) {
3953  fArrayPNE->Add(obj);
3954  }
3955  return kTRUE;
3956  }
3957  return kFALSE;
3958 }
3959 
3960 ////////////////////////////////////////////////////////////////////////////////
3961 /// Get time cut for drawing tracks.
3962 
3964 {
3965  tmin = fTmin;
3966  tmax = fTmax;
3967  return fTimeCut;
3968 }
3969 
3970 ////////////////////////////////////////////////////////////////////////////////
3971 /// Set time cut interval for drawing tracks. If called with no arguments, time
3972 /// cut will be disabled.
3973 
3975 {
3976  fTmin = tmin;
3977  fTmax = tmax;
3978  if (tmin==0 && tmax==999) fTimeCut = kFALSE;
3979  else fTimeCut = kTRUE;
3980  if (fTracks && !IsAnimatingTracks()) ModifiedPad();
3981 }
3982 
3983 ////////////////////////////////////////////////////////////////////////////////
3984 /// Convert coordinates from master volume frame to top.
3985 
3986 void TGeoManager::MasterToTop(const Double_t *master, Double_t *top) const
3987 {
3988  GetCurrentNavigator()->MasterToLocal(master, top);
3989 }
3990 
3991 ////////////////////////////////////////////////////////////////////////////////
3992 /// Convert coordinates from top volume frame to master.
3993 
3994 void TGeoManager::TopToMaster(const Double_t *top, Double_t *master) const
3995 {
3996  GetCurrentNavigator()->LocalToMaster(top, master);
3997 }
3998 
3999 ////////////////////////////////////////////////////////////////////////////////
4000 /// Create a parallel world for prioritised navigation. This can be populated
4001 /// with physical nodes and can be navigated independently using its API.
4002 /// In case the flag SetUseParallelWorldNav is set, any navigation query in the
4003 /// main geometry is checked against the parallel geometry, which gets priority
4004 /// in case of overlaps with the main geometry volumes.
4005 
4007 {
4008  fParallelWorld = new TGeoParallelWorld(name, this);
4009  return fParallelWorld;
4010 }
4011 
4012 ////////////////////////////////////////////////////////////////////////////////
4013 /// Activate/deactivate usage of parallel world navigation. Can only be done if
4014 /// there is a parallel world. Activating navigation will automatically close
4015 /// the parallel geometry.
4016 
4018 {
4019  if (!fParallelWorld) {
4020  Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
4021  return;
4022  }
4023  if (!flag) {
4024  fUsePWNav = flag;
4025  return;
4026  }
4027  if (!fClosed) {
4028  Error("SetUseParallelWorldNav", "The geometry must be closed first");
4029  return;
4030  }
4031  // Closing the parallel world geometry is mandatory
4033 }
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:85
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:53
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:94
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:86
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:114
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:80
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:78
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:687
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:406
std::map< std::thread::id, Int_t > ThreadsMap_t
Definition: TGeoManager.h:102
virtual void Test(Int_t npoints, Option_t *option)=0
THashList * fHashVolumes
Definition: TGeoManager.h:123
TGeoMaterial * GetMaterial() const
Definition: TGeoMedium.h:52
TVirtualGeoTrack * GetTrack(Int_t index)
Definition: TGeoManager.h:376
void Init()
Initialize manager class.
#define BIT(n)
Definition: Rtypes.h:78
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:47
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:79
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:67
Int_t fNtracks
Definition: TGeoManager.h:65
static void SetDoubleFormat(const char *fmt="%.14e")
set printf format for double members, default "%.14e" use it after SetFloatFormat, which also overwrites format for doubles
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:57
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:410
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:69
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:131
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.
#define f(i)
Definition: RSha256.hxx:104
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1100
TObjArray * fUniqueVolumes
Definition: TGeoManager.h:115
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:112
Bool_t fIsNodeSelectable
switch ON/OFF volume activity (default OFF - all volumes active))
Definition: TGeoManager.h:81
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:62
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:116
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:77
TObjArray * fPdgNames
Definition: TGeoManager.h:91
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:126
TObjArray * fGShapes
Definition: TGeoManager.h:88
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:3976
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:96
Int_t fNsegments
Definition: TGeoManager.h:64
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:74
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
TObjArray * fMatrices
current painter
Definition: TGeoManager.h:84
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:135
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 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:2286
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:124
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:56
static Bool_t IsLocked()
Check lock state.
THashList * fHashPNE
hash list of group volumes providing fast search
Definition: TGeoManager.h:125
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:109
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:111
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:514
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:128
virtual TGeoMatrix * GetMatrix() const =0
static Int_t fgNumThreads
Thread id&#39;s map.
Definition: TGeoManager.h:107
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:103
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:678
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:75
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:105
TGeoNavigatorArray * GetListOfNavigators() const
Get list of navigators for the calling thread.
Bool_t fIsGeomReading
Definition: TGeoManager.h:73
Int_t fVisLevel
Definition: TGeoManager.h:63
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:490
Bool_t IsAnimatingTracks() const
Definition: TGeoManager.h:388
static Int_t fgVerboseLevel
Lock preventing a second geometry to be loaded.
Definition: TGeoManager.h:43
static UInt_t GetExportPrecision()
Definition: TGeoManager.h:457
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:131
Int_t * fKeyPNEId
Definition: TGeoManager.h:129
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:71
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:55
void RemoveNavigator(const TGeoNavigator *nav)
Clear a single navigator.
TObjArray * fPhysicalNodes
Definition: TGeoManager.h:87
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
Bool_t fTimeCut
Definition: TGeoManager.h:76
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:119
Int_t fNLevel
array of node id&#39;s
Definition: TGeoManager.h:120
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:61
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:54
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:440
void RefreshPhysicalNodes()
Refresh the node pointers and re-voxelize.
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t fMaxVisNodes
Definition: TGeoManager.h:66
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:405
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:68
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1081
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:90
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:60
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:93
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:130
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:72
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:95
constexpr Double_t E()
Base of natural log: .
Definition: TMath.h:97
#define h(i)
Definition: RSha256.hxx:106
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:89
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:110
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:133
void DefaultAngles()
Set default angles for a given view.
Bool_t IsClosed() const
#define SafeDelete(p)
Definition: RConfig.h:529
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:546
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:82
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
static void SetFloatFormat(const char *fmt="%e")
set printf format for float/double members, default "%e" to change format only for doubles...
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:619
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:108
TObjArray * GetListOfPhysicalNodes()
Definition: TGeoManager.h:463
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:544
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:134
Bool_t SetCurrentNavigator(Int_t index)
Switch to another existing navigator for the calling thread.
Bool_t fClosed
Definition: TGeoManager.h:70
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.
static const char * GetDoubleFormat()
return current printf format for double members, default "%.14e"
void ResetAll()
Reset the navigator.
static ThreadsMap_t * fgThreadId
Map between thread id&#39;s and navigator arrays.
Definition: TGeoManager.h:106
Bool_t IsNull() const
Definition: TString.h:402
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()
Conversion from radian to degree: .
Definition: TMath.h:74
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:192
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:117
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:127
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:122
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:393
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:97
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
static const char * GetFloatFormat()
return current printf format for float members, default "%e"
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:540
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:132
UChar_t * fBits
Definition: TGeoManager.h:98
TString fParticleName
path to current node
Definition: TGeoManager.h:59
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:121
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
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
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:113
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
static UInt_t fgExportPrecision
Maximum number of Xtru vertices.
Definition: TGeoManager.h:47
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)
Binary search in an array of n values to locate value.
Definition: TMath.h:1221
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:364
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...