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