ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ////////////////////////////////////////////////////////////////////////////////
13 // General architecture
14 // --------------------
15 //
16 // The new ROOT geometry package is a tool designed for building, browsing,
17 // tracking and visualizing a detector geometry. The code is independent from
18 // other external MC for simulation, therefore it does not contain any
19 // constraints related to physics. However, the package defines a number of
20 // hooks for tracking, such as media, materials, magnetic field or track state flags,
21 // in order to allow interfacing to tracking MC's. The final goal is to be
22 // able to use the same geometry for several purposes, such as tracking,
23 // reconstruction or visualization, taking advantage of the ROOT features
24 // related to bookkeeping, I/O, histograming, browsing and GUI's.
25 //
26 // The geometrical modeler is the most important component of the package and
27 // it provides answers to the basic questions like "Where am I ?" or "How far
28 // from the next boundary ?", but also to more complex ones like "How far from
29 // the closest surface ?" or "Which is the next crossing along a helix ?".
30 //
31 // The architecture of the modeler is a combination between a GEANT-like
32 // containment scheme and a normal CSG binary tree at the level of shapes. An
33 // important common feature of all detector geometry descriptions is the
34 // mother-daughter concept. This is the most natural approach when tracking
35 // is concerned and imposes a set of constraints to the way geometry is defined.
36 // Constructive solid geometry composition is used only in order to create more
37 // complex shapes from an existing set of primitives through boolean operations.
38 // This feature is not implemented yet but in future full definition of boolean
39 // expressions will be supported.
40 //
41 // Practically every geometry defined in GEANT style can be mapped by the modeler.
42 // The basic components used for building the logical hierarchy of the geometry
43 // are called "volumes" and "nodes". Volumes (sometimes called "solids") are fully
44 // defined geometrical objects having a given shape and medium and possibly
45 // containing a list of nodes. Nodes represent just positioned instances of volumes
46 // inside a container volume and they are not directly defined by user. They are
47 // automatically created as a result of adding one volume inside other or dividing
48 // a volume. The geometrical transformation hold by nodes is always defined with
49 // respect to their mother (relative positioning). Reflection matrices are allowed.
50 // All volumes have to be fully aware of their containees when the geometry is
51 // closed. They will build aditional structures (voxels) in order to fasten-up
52 // the search algorithms. Finally, nodes can be regarded as bidirectional links
53 // between containers and containees objects.
54 //
55 // The structure defined in this way is a graph structure since volumes are
56 // replicable (same volume can become daughter node of several other volumes),
57 // every volume becoming a branch in this graph. Any volume in the logical graph
58 // can become the actual top volume at run time (see TGeoManager::SetTopVolume()).
59 // All functionalities of the modeler will behave in this case as if only the
60 // corresponding branch starting from this volume is the registered geometry.
61 //
62 //Begin_Html
63 /*
64 <img src="gif/t_graf.jpg">
65 */
66 //End_Html
67 //
68 // A given volume can be positioned several times in the geometry. A volume
69 // can be divided according default or user-defined patterns, creating automatically
70 // the list of division nodes inside. The elementary volumes created during the
71 // dividing process follow the same scheme as usual volumes, therefore it is possible
72 // to position further geometrical structures inside or to divide them further more
73 // (see TGeoVolume::Divide()).
74 //
75 // The primitive shapes supported by the package are basically the GEANT3
76 // shapes (see class TGeoShape), arbitrary wedges with eight vertices on two parallel
77 // planes. All basic primitives inherits from class TGeoBBox since the bounding box
78 // of a solid is essential for the tracking algorithms. They also implement the
79 // virtual methods defined in the virtual class TGeoShape (point and segment
80 // classification). User-defined primitives can be direcly plugged into the modeler
81 // provided that they override these methods. Composite shapes will be soon supported
82 // by the modeler. In order to build a TGeoCompositeShape, one will have to define
83 // first the primitive components. The object that handle boolean
84 // operations among components is called TGeoBoolCombinator and it has to be
85 // constructed providing a string boolean expression between the components names.
86 //
87 //
88 // Example for building a simple geometry :
89 //-----------------------------------------
90 //
91 // Begin_Html <a href=http://root.cern.ch/root/html/tutorials/geom/rootgeom.C.html>rootgeom.C</a> //
92 // End_Html //
93 //______________________________________________________________________________
94 //
95 //
96 //Begin_Html
97 /*
98 <img src="gif/t_root.jpg">
99 */
100 //End_Html
101 //
102 //
103 // TGeoManager - the manager class for the geometry package.
104 // ---------------------------------------------------------
105 //
106 // TGeoManager class is embedding all the API needed for building and tracking
107 // a geometry. It defines a global pointer (gGeoManager) in order to be fully
108 // accessible from external code. The mechanism of handling multiple geometries
109 // at the same time will be soon implemented.
110 //
111 // TGeoManager is the owner of all geometry objects defined in a session,
112 // therefore users must not try to control their deletion. It contains lists of
113 // media, materials, transformations, shapes and volumes. Logical nodes (positioned
114 // volumes) are created and destroyed by the TGeoVolume class. Physical
115 // nodes and their global transformations are subjected to a caching mechanism
116 // due to the sometimes very large memory requirements of logical graph expansion.
117 // The caching mechanism is triggered by the total number of physical instances
118 // of volumes and the cache manager is a client of TGeoManager. The manager class
119 // also controls the painter client. This is linked with ROOT graphical libraries
120 // loaded on demand in order to control visualization actions.
121 //
122 // Rules for building a valid geometry
123 // -----------------------------------
124 //
125 // A given geometry can be built in various ways, but there are mandatory steps
126 // that have to be followed in order to be validated by the modeler. There are
127 // general rules : volumes needs media and shapes in order to be created,
128 // both container an containee volumes must be created before linking them together,
129 // and the relative transformation matrix must be provided. All branches must
130 // have an upper link point otherwise they will not be considered as part of the
131 // geometry. Visibility or tracking properties of volumes can be provided both
132 // at build time or after geometry is closed, but global visualization settings
133 // (see TGeoPainter class) should not be provided at build time, otherwise the
134 // drawing package will be loaded. There is also a list of specific rules :
135 // positioned daughters should not extrude their mother or intersect with sisters
136 // unless this is specified (see TGeoVolume::AddNodeOverlap()), the top volume
137 // (containing all geometry tree) must be specified before closing the geometry
138 // and must not be positioned - it represents the global reference frame. After
139 // building the full geometry tree, the geometry must be closed
140 // (see TGeoManager::CloseGeometry()). Voxelization can be redone per volume after
141 // this process.
142 //
143 //
144 // Below is the general scheme of the manager class.
145 //
146 //Begin_Html
147 /*
148 <img src="gif/t_mgr.jpg">
149 */
150 //End_Html
151 //
152 // An interactive session
153 // ------------------------
154 //
155 // Provided that a geometry was successfully built and closed (for instance the
156 // previous example $ROOTSYS/tutorials/geom/rootgeom.C ), the manager class will register
157 // itself to ROOT and the logical/physical structures will become immediately browsable.
158 // The ROOT browser will display starting from the geometry folder : the list of
159 // transformations and media, the top volume and the top logical node. These last
160 // two can be fully expanded, any intermediate volume/node in the browser being subject
161 // of direct access context menu operations (right mouse button click). All user
162 // utilities of classes TGeoManager, TGeoVolume and TGeoNode can be called via the
163 // context menu.
164 //
165 //Begin_Html
166 /*
167 <img src="gif/t_browser.jpg">
168 */
169 //End_Html
170 //
171 // --- Drawing the geometry
172 //
173 // Any logical volume can be drawn via TGeoVolume::Draw() member function.
174 // This can be direcly accessed from the context menu of the volume object
175 // directly from the browser.
176 // There are several drawing options that can be set with
177 // TGeoManager::SetVisOption(Int_t opt) method :
178 // opt=0 - only the content of the volume is drawn, N levels down (default N=3).
179 // This is the default behavior. The number of levels to be drawn can be changed
180 // via TGeoManager::SetVisLevel(Int_t level) method.
181 //
182 //Begin_Html
183 /*
184 <img src="gif/t_frame0.jpg">
185 */
186 //End_Html
187 //
188 // opt=1 - the final leaves (e.g. daughters with no containment) of the branch
189 // starting from volume are drawn down to the current number of levels.
190 // WARNING : This mode is memory consuming
191 // depending of the size of geometry, so drawing from top level within this mode
192 // should be handled with care for expensive geometries. In future there will be
193 // a limitation on the maximum number of nodes to be visualized.
194 //
195 //Begin_Html
196 /*
197 <img src="gif/t_frame1.jpg">
198 */
199 //End_Html
200 //
201 // opt=2 - only the clicked volume is visualized. This is automatically set by
202 // TGeoVolume::DrawOnly() method
203 // opt=3 - only a given path is visualized. This is automatically set by
204 // TGeoVolume::DrawPath(const char *path) method
205 //
206 // The current view can be exploded in cartesian, cylindrical or spherical
207 // coordinates :
208 // TGeoManager::SetExplodedView(Int_t opt). Options may be :
209 // - 0 - default (no bombing)
210 // - 1 - cartesian coordinates. The bomb factor on each axis can be set with
211 // TGeoManager::SetBombX(Double_t bomb) and corresponding Y and Z.
212 // - 2 - bomb in cylindrical coordinates. Only the bomb factors on Z and R
213 // are considered
214 //
215 //Begin_Html
216 /*
217 <img src="gif/t_frameexp.jpg">
218 */
219 //End_Html
220 //
221 // - 3 - bomb in radial spherical coordinate : TGeoManager::SetBombR()
222 //
223 // Volumes themselves support different visualization settings :
224 // - TGeoVolume::SetVisibility() : set volume visibility.
225 // - TGeoVolume::VisibleDaughters() : set daughters visibility.
226 // All these actions automatically updates the current view if any.
227 //
228 // --- Checking the geometry
229 //
230 // Several checking methods are accessible from the volume context menu. They
231 // generally apply only to the visible parts of the drawn geometry in order to
232 // ease geometry checking, and their implementation is in the TGeoChecker class
233 // from the painting package.
234 //
235 // 1. Checking a given point.
236 // Can be called from TGeoManager::CheckPoint(Double_t x, Double_t y, Double_t z).
237 // This method is drawing the daughters of the volume containing the point one
238 // level down, printing the path to the deepest physical node holding this point.
239 // It also computes the closest distance to any boundary. The point will be drawn
240 // in red.
241 //
242 //Begin_Html
243 /*
244 <img src="gif/t_checkpoint.jpg">
245 */
246 //End_Html
247 //
248 // 2. Shooting random points.
249 // Can be called from TGeoVolume::RandomPoints() (context menu function) and
250 // it will draw this volume with current visualization settings. Random points
251 // are generated in the bounding box of the top drawn volume. The points are
252 // classified and drawn with the color of their deepest container. Only points
253 // in visible nodes will be drawn.
254 //
255 //Begin_Html
256 /*
257 <img src="gif/t_random1.jpg">
258 */
259 //End_Html
260 //
261 //
262 // 3. Raytracing.
263 // Can be called from TGeoVolume::RandomRays() (context menu of volumes) and
264 // will shoot rays from a given point in the local reference frame with random
265 // directions. The intersections with displayed nodes will appear as segments
266 // having the color of the touched node. Drawn geometry will be then made invisible
267 // in order to enhance rays.
268 //
269 //Begin_Html
270 /*
271 <img src="gif/t_random2.jpg">
272 */
273 //End_Html
274 
275 #include <stdlib.h>
276 
277 #include "Riostream.h"
278 
279 #include "TROOT.h"
280 #include "TGeoManager.h"
281 #include "TSystem.h"
282 #include "TStyle.h"
283 #include "TVirtualPad.h"
284 #include "TBrowser.h"
285 #include "TFile.h"
286 #include "TKey.h"
287 #include "THashList.h"
288 #include "TClass.h"
289 #include "TThread.h"
290 #include "ThreadLocalStorage.h"
291 
292 #include "TGeoVoxelFinder.h"
293 #include "TGeoElement.h"
294 #include "TGeoMaterial.h"
295 #include "TGeoMedium.h"
296 #include "TGeoMatrix.h"
297 #include "TGeoNode.h"
298 #include "TGeoPhysicalNode.h"
299 #include "TGeoManager.h"
300 #include "TGeoPara.h"
301 #include "TGeoParaboloid.h"
302 #include "TGeoTube.h"
303 #include "TGeoEltu.h"
304 #include "TGeoHype.h"
305 #include "TGeoCone.h"
306 #include "TGeoSphere.h"
307 #include "TGeoArb8.h"
308 #include "TGeoPgon.h"
309 #include "TGeoTrd1.h"
310 #include "TGeoTrd2.h"
311 #include "TGeoTorus.h"
312 #include "TGeoXtru.h"
313 #include "TGeoCompositeShape.h"
314 #include "TGeoBoolNode.h"
315 #include "TGeoBuilder.h"
316 #include "TVirtualGeoPainter.h"
317 #include "TPluginManager.h"
318 #include "TVirtualGeoTrack.h"
319 #include "TQObject.h"
320 #include "TMath.h"
321 #include "TEnv.h"
322 #include "TGeoParallelWorld.h"
323 
324 // statics and globals
325 
326 TGeoManager *gGeoManager = 0;
327 
329 
330 Bool_t TGeoManager::fgLock = kFALSE;
331 Bool_t TGeoManager::fgLockNavigators = kFALSE;
332 Int_t TGeoManager::fgVerboseLevel = 1;
333 Int_t TGeoManager::fgMaxLevel = 1;
334 Int_t TGeoManager::fgMaxDaughters = 1;
335 Int_t TGeoManager::fgMaxXtruVert = 1;
336 Int_t TGeoManager::fgNumThreads = 0;
337 TGeoManager::ThreadsMap_t *TGeoManager::fgThreadId = 0;
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 /// Default constructor.
341 
343 {
344  if (!fgThreadId) fgThreadId = new TGeoManager::ThreadsMap_t;
346  fTimeCut = kFALSE;
347  fTmin = 0.;
348  fTmax = 999.;
349  fPhiCut = kFALSE;
350  fPhimin = 0;
351  fPhimax = 360;
352  fDrawExtra = kFALSE;
353  fStreamVoxels = kFALSE;
354  fIsGeomReading = kFALSE;
355  fIsGeomCleaning = kFALSE;
356  fClosed = kFALSE;
357  fLoopVolumes = kFALSE;
358  fBits = 0;
359  fCurrentNavigator = 0;
360  fMaterials = 0;
361  fHashPNE = 0;
362  fArrayPNE = 0;
363  fMatrices = 0;
364  fNodes = 0;
365  fOverlaps = 0;
366  fNNodes = 0;
367  fMaxVisNodes = 10000;
368  fVolumes = 0;
369  fPhysicalNodes = 0;
370  fShapes = 0;
371  fGVolumes = 0;
372  fGShapes = 0;
373  fTracks = 0;
374  fMedia = 0;
375  fNtracks = 0;
376  fNpdg = 0;
377  fPdgNames = 0;
378  memset(fPdgId, 0, 1024*sizeof(Int_t));
379  fCurrentTrack = 0;
380  fCurrentVolume = 0;
381  fTopVolume = 0;
382  fTopNode = 0;
383  fMasterVolume = 0;
384  fPainter = 0;
385  fActivity = kFALSE;
386  fIsNodeSelectable = kFALSE;
387  fVisDensity = 0.;
388  fVisLevel = 3;
389  fVisOption = 1;
390  fExplodedView = 0;
391  fNsegments = 20;
392  fNLevel = 0;
393  fUniqueVolumes = 0;
394  fNodeIdArray = 0;
395  fClippingShape = 0;
396  fMatrixTransform = kFALSE;
397  fMatrixReflection = kFALSE;
398  fGLMatrix = 0;
399  fPaintVolume = 0;
400  fElementTable = 0;
401  fHashVolumes = 0;
402  fHashGVolumes = 0;
403  fSizePNEId = 0;
404  fNPNEId = 0;
405  fKeyPNEId = 0;
406  fValuePNEId = 0;
407  fMultiThread = kFALSE;
408  fMaxThreads = 0;
409  fUsePWNav = kFALSE;
410  fParallelWorld = 0;
411  ClearThreadsMap();
412  } else {
413  Init();
415  BuildDefaultMaterials();
416  }
417 }
418 
419 ////////////////////////////////////////////////////////////////////////////////
420 /// Constructor.
421 
422 TGeoManager::TGeoManager(const char *name, const char *title)
423  :TNamed(name, title)
424 {
425  if (!gROOT->GetListOfGeometries()->FindObject(this)) gROOT->GetListOfGeometries()->Add(this);
426  if (!gROOT->GetListOfBrowsables()->FindObject(this)) gROOT->GetListOfBrowsables()->Add(this);
427  Init();
428  gGeoIdentity = new TGeoIdentity("Identity");
430  if (fgVerboseLevel>0) Info("TGeoManager","Geometry %s, %s created", GetName(), GetTitle());
431 }
432 
433 ////////////////////////////////////////////////////////////////////////////////
434 /// Initialize manager class.
435 
437 {
438  if (gGeoManager) {
439  Warning("Init","Deleting previous geometry: %s/%s",gGeoManager->GetName(),gGeoManager->GetTitle());
440  delete gGeoManager;
441  if (fgLock) Fatal("Init", "New geometry created while the old one locked !!!");
442  }
443 
444  gGeoManager = this;
446  fTimeCut = kFALSE;
447  fTmin = 0.;
448  fTmax = 999.;
449  fPhiCut = kFALSE;
450  fPhimin = 0;
451  fPhimax = 360;
452  fDrawExtra = kFALSE;
456  fClosed = kFALSE;
458  fBits = new UChar_t[50000]; // max 25000 nodes per volume
459  fCurrentNavigator = 0;
460  fHashPNE = new THashList(256,3);
461  fArrayPNE = 0;
462  fMaterials = new THashList(200,3);
463  fMatrices = new TObjArray(256);
464  fNodes = new TObjArray(30);
465  fOverlaps = new TObjArray(256);
466  fNNodes = 0;
467  fMaxVisNodes = 10000;
468  fVolumes = new TObjArray(256);
469  fPhysicalNodes = new TObjArray(256);
470  fShapes = new TObjArray(256);
471  fGVolumes = new TObjArray(256);
472  fGShapes = new TObjArray(256);
473  fTracks = new TObjArray(256);
474  fMedia = new THashList(200,3);
475  fNtracks = 0;
476  fNpdg = 0;
477  fPdgNames = 0;
478  memset(fPdgId, 0, 1024*sizeof(Int_t));
479  fCurrentTrack = 0;
480  fCurrentVolume = 0;
481  fTopVolume = 0;
482  fTopNode = 0;
483  fMasterVolume = 0;
484  fPainter = 0;
485  fActivity = kFALSE;
487  fVisDensity = 0.;
488  fVisLevel = 3;
489  fVisOption = 1;
490  fExplodedView = 0;
491  fNsegments = 20;
492  fNLevel = 0;
493  fUniqueVolumes = new TObjArray(256);
494  fNodeIdArray = 0;
495  fClippingShape = 0;
498  fGLMatrix = new TGeoHMatrix();
499  fPaintVolume = 0;
500  fElementTable = 0;
501  fHashVolumes = 0;
502  fHashGVolumes = 0;
503  fSizePNEId = 0;
504  fNPNEId = 0;
505  fKeyPNEId = 0;
506  fValuePNEId = 0;
508  fMaxThreads = 0;
509  fUsePWNav = kFALSE;
510  fParallelWorld = 0;
511  ClearThreadsMap();
512 }
513 
514 ////////////////////////////////////////////////////////////////////////////////
515 ///copy constructor
516 
518  TNamed(gm),
519  fPhimin(gm.fPhimin),
520  fPhimax(gm.fPhimax),
521  fTmin(gm.fTmin),
522  fTmax(gm.fTmax),
523  fNNodes(gm.fNNodes),
524  fParticleName(gm.fParticleName),
525  fVisDensity(gm.fVisDensity),
526  fExplodedView(gm.fExplodedView),
527  fVisOption(gm.fVisOption),
528  fVisLevel(gm.fVisLevel),
529  fNsegments(gm.fNsegments),
530  fNtracks(gm.fNtracks),
531  fMaxVisNodes(gm.fMaxVisNodes),
532  fCurrentTrack(gm.fCurrentTrack),
533  fNpdg(gm.fNpdg),
534  fClosed(gm.fClosed),
535  fLoopVolumes(gm.fLoopVolumes),
536  fStreamVoxels(gm.fStreamVoxels),
537  fIsGeomReading(gm.fIsGeomReading),
538  fIsGeomCleaning(kFALSE),
539  fPhiCut(gm.fPhiCut),
540  fTimeCut(gm.fTimeCut),
541  fDrawExtra(gm.fDrawExtra),
542  fMatrixTransform(gm.fMatrixTransform),
543  fMatrixReflection(gm.fMatrixReflection),
544  fActivity(gm.fActivity),
545  fIsNodeSelectable(gm.fIsNodeSelectable),
546  fPainter(gm.fPainter),
547  fMatrices(gm.fMatrices),
548  fShapes(gm.fShapes),
549  fVolumes(gm.fVolumes),
550  fPhysicalNodes(gm.fPhysicalNodes),
551  fGShapes(gm.fGShapes),
552  fGVolumes(gm.fGVolumes),
553  fTracks(gm.fTracks),
554  fPdgNames(gm.fPdgNames),
555  fMaterials(gm.fMaterials),
556  fMedia(gm.fMedia),
557  fNodes(gm.fNodes),
558  fOverlaps(gm.fOverlaps),
559  fBits(gm.fBits),
560  fCurrentNavigator(gm.fCurrentNavigator),
561  fCurrentVolume(gm.fCurrentVolume),
562  fTopVolume(gm.fTopVolume),
563  fTopNode(gm.fTopNode),
564  fMasterVolume(gm.fMasterVolume),
565  fGLMatrix(gm.fGLMatrix),
566  fUniqueVolumes(gm.fUniqueVolumes),
567  fClippingShape(gm.fClippingShape),
568  fElementTable(gm.fElementTable),
569  fNodeIdArray(gm.fNodeIdArray),
570  fNLevel(gm.fNLevel),
571  fPaintVolume(gm.fPaintVolume),
572  fHashVolumes(gm.fHashVolumes),
573  fHashGVolumes(gm.fHashGVolumes),
574  fHashPNE(gm.fHashPNE),
575  fArrayPNE(gm.fArrayPNE),
576  fSizePNEId(0),
577  fNPNEId(0),
578  fKeyPNEId(0),
579  fValuePNEId(0),
580  fMaxThreads(0),
581  fMultiThread(kFALSE),
582  fUsePWNav(kFALSE),
583  fParallelWorld(0)
584 {
585  for(Int_t i=0; i<1024; i++)
586  fPdgId[i]=gm.fPdgId[i];
588  ClearThreadsMap();
589 }
590 
591 ////////////////////////////////////////////////////////////////////////////////
592 ///assignment operator
593 
595 {
597  if(this!=&gm) {
598  TNamed::operator=(gm);
599  fPhimin=gm.fPhimin;
600  fPhimax=gm.fPhimax;
601  fTmin=gm.fTmin;
602  fTmax=gm.fTmax;
603  fNNodes=gm.fNNodes;
608  fVisLevel=gm.fVisLevel;
610  fNtracks=gm.fNtracks;
613  fNpdg=gm.fNpdg;
614  for(Int_t i=0; i<1024; i++)
615  fPdgId[i]=gm.fPdgId[i];
616  fClosed=gm.fClosed;
621  fPhiCut=gm.fPhiCut;
622  fTimeCut=gm.fTimeCut;
626  fActivity=gm.fActivity;
628  fPainter=gm.fPainter;
629  fMatrices=gm.fMatrices;
630  fShapes=gm.fShapes;
631  fVolumes=gm.fVolumes;
633  fGShapes=gm.fGShapes;
634  fGVolumes=gm.fGVolumes;
635  fTracks=gm.fTracks;
636  fPdgNames=gm.fPdgNames;
638  fMedia=gm.fMedia;
639  fNodes=gm.fNodes;
640  fOverlaps=gm.fOverlaps;
641  fBits=gm.fBits;
645  fTopNode=gm.fTopNode;
647  fGLMatrix=gm.fGLMatrix;
652  fNLevel=gm.fNLevel;
656  fHashPNE=gm.fHashPNE;
657  fArrayPNE=gm.fArrayPNE;
658  fSizePNEId = 0;
659  fNPNEId = 0;
660  fKeyPNEId = 0;
661  fValuePNEId = 0;
663  fMaxThreads = 0;
664  fUsePWNav = kFALSE;
665  fParallelWorld = 0;
666  ClearThreadsMap();
667  ClearThreadData();
668  }
669  return *this;
670 }
671 
672 ////////////////////////////////////////////////////////////////////////////////
673 /// Destructor
674 
676 {
677  if (gGeoManager != this) gGeoManager = this;
679 
680  if (gROOT->GetListOfFiles()) { //in case this function is called from TROOT destructor
681  gROOT->GetListOfGeometries()->Remove(this);
682  gROOT->GetListOfBrowsables()->Remove(this);
683  }
684 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
685 // TIter next(brlist);
686 // TBrowser *browser = 0;
687 // while ((browser=(TBrowser*)next())) browser->RecursiveRemove(this);
688  ClearThreadsMap();
689  ClearThreadData();
690  delete TGeoBuilder::Instance(this);
691  if (fBits) delete [] fBits;
697  if (fMedia) {fMedia->Delete(); SafeDelete(fMedia);}
701  if (fArrayPNE) {delete fArrayPNE;}
703  if (fShapes) {fShapes->Delete(); SafeDelete( fShapes );}
706  if (fTracks) {fTracks->Delete(); SafeDelete( fTracks );}
709  ClearNavigators();
710  CleanGarbage();
711  SafeDelete( fPainter );
713  if (fSizePNEId) {
714  delete [] fKeyPNEId;
715  delete [] fValuePNEId;
716  }
717  delete fParallelWorld;
719  gGeoIdentity = 0;
720  gGeoManager = 0;
721 }
722 
723 ////////////////////////////////////////////////////////////////////////////////
724 /// Add a material to the list. Returns index of the material in list.
725 
727 {
728  return TGeoBuilder::Instance(this)->AddMaterial((TGeoMaterial*)material);
729 }
730 
731 ////////////////////////////////////////////////////////////////////////////////
732 /// Add an illegal overlap/extrusion to the list.
733 
735 {
736  Int_t size = fOverlaps->GetEntriesFast();
737  fOverlaps->Add((TObject*)ovlp);
738  return size;
739 }
740 
741 ////////////////////////////////////////////////////////////////////////////////
742 /// Add a matrix to the list. Returns index of the matrix in list.
743 
745 {
746  return TGeoBuilder::Instance(this)->AddTransformation((TGeoMatrix*)matrix);
747 }
748 
749 ////////////////////////////////////////////////////////////////////////////////
750 /// Add a shape to the list. Returns index of the shape in list.
751 
753 {
754  return TGeoBuilder::Instance(this)->AddShape((TGeoShape*)shape);
755 }
756 
757 ////////////////////////////////////////////////////////////////////////////////
758 /// Add a track to the list of tracks. Use this for primaries only. For secondaries,
759 /// add them to the parent track. The method create objects that are registered
760 /// to the analysis manager but have to be cleaned-up by the user via ClearTracks().
761 
763 {
764  Int_t index = fNtracks;
765  fTracks->AddAtAndExpand(GetGeomPainter()->AddTrack(id,pdgcode,particle),fNtracks++);
766  return index;
767 }
768 
769 ////////////////////////////////////////////////////////////////////////////////
770 /// Add a track to the list of tracks
771 
773 {
774  Int_t index = fNtracks;
775  fTracks->AddAtAndExpand(track,fNtracks++);
776  return index;
777 }
778 
779 ////////////////////////////////////////////////////////////////////////////////
780 /// Makes a primary track but do not attach it to the list of tracks. The track
781 /// can be attached as daughter to another one with TVirtualGeoTrack::AddTrack
782 
784 {
785  TVirtualGeoTrack *track = GetGeomPainter()->AddTrack(id,pdgcode,particle);
786  return track;
787 }
788 
789 ////////////////////////////////////////////////////////////////////////////////
790 /// Add a volume to the list. Returns index of the volume in list.
791 
793 {
794  if (!volume) {
795  Error("AddVolume", "invalid volume");
796  return -1;
797  }
799  if (!uid) uid++;
800  if (!fCurrentVolume) {
801  fCurrentVolume = volume;
802  fUniqueVolumes->AddAtAndExpand(volume,uid);
803  } else {
804  if (!strcmp(volume->GetName(), fCurrentVolume->GetName())) {
805  uid = fCurrentVolume->GetNumber();
806  } else {
807  fCurrentVolume = volume;
808  Int_t olduid = GetUID(volume->GetName());
809  if (olduid<0) {
810  fUniqueVolumes->AddAtAndExpand(volume,uid);
811  } else {
812  uid = olduid;
813  }
814  }
815  }
816  volume->SetNumber(uid);
817  if (!fHashVolumes) {
818  fHashVolumes = new THashList(256);
819  fHashGVolumes = new THashList(256);
820  }
821  TObjArray *list = fVolumes;
822  if (!volume->GetShape() || volume->IsRunTime() || volume->IsVolumeMulti()) {
823  list = fGVolumes;
824  fHashGVolumes->Add(volume);
825  } else {
826  fHashVolumes->Add(volume);
827  }
828  Int_t index = list->GetEntriesFast();
829  list->AddAtAndExpand(volume,index);
830  return uid;
831 }
832 
833 ////////////////////////////////////////////////////////////////////////////////
834 /// Add a navigator in the list of navigators. If it is the first one make it
835 /// current navigator.
836 
838 {
840 // if (fgLockNavigators) {
841 // Error("AddNavigator", "Navigators are locked. Use SetNavigatorsLock(false) first.");
842 // return 0;
843 // }
844  Long_t threadId = fMultiThread ? TThread::SelfId() : 0;
845  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
846  TGeoNavigatorArray *array = 0;
847  if (it != fNavigators.end()) array = it->second;
848  else {
849  array = new TGeoNavigatorArray(this);
850  fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
851  }
852  TGeoNavigator *nav = array->AddNavigator();
853  if (fClosed) nav->GetCache()->BuildInfoBranch();
854  if (fMultiThread) TThread::UnLock();
855  return nav;
856 }
857 
858 ////////////////////////////////////////////////////////////////////////////////
859 /// Returns current navigator for the calling thread.
860 
862 {
863  TTHREAD_TLS(TGeoNavigator*) tnav = 0;
864  if (!fMultiThread) return fCurrentNavigator;
865  TGeoNavigator *nav = tnav; // TTHREAD_TLS_GET(TGeoNavigator*,tnav);
866  if (nav) return nav;
867  Long_t threadId = TThread::SelfId();
868  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
869  if (it == fNavigators.end()) return 0;
870  TGeoNavigatorArray *array = it->second;
871  nav = array->GetCurrentNavigator();
872  tnav = nav; // TTHREAD_TLS_SET(TGeoNavigator*,tnav,nav);
873  return nav;
874 }
875 
876 ////////////////////////////////////////////////////////////////////////////////
877 /// Get list of navigators for the calling thread.
878 
880 {
881  Long_t threadId = fMultiThread ? TThread::SelfId() : 0;
882  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
883  if (it == fNavigators.end()) return 0;
884  TGeoNavigatorArray *array = it->second;
885  return array;
886 }
887 
888 ////////////////////////////////////////////////////////////////////////////////
889 /// Switch to another existing navigator for the calling thread.
890 
892 {
893  Long_t threadId = fMultiThread ? TThread::SelfId() : 0;
894  NavigatorsMap_t::const_iterator it = fNavigators.find(threadId);
895  if (it == fNavigators.end()) {
896  Error("SetCurrentNavigator", "No navigator defined for thread %ld\n", threadId);
897  return kFALSE;
898  }
899  TGeoNavigatorArray *array = it->second;
900  TGeoNavigator *nav = array->SetCurrentNavigator(index);
901  if (!nav) {
902  Error("SetCurrentNavigator", "Navigator %d not existing for thread %ld\n", index, threadId);
903  return kFALSE;
904  }
905  if (!fMultiThread) fCurrentNavigator = nav;
906  return kTRUE;
907 }
908 
909 ////////////////////////////////////////////////////////////////////////////////
910 /// Set the lock for navigators.
911 
913 {
914  fgLockNavigators = flag;
915 }
916 
917 ////////////////////////////////////////////////////////////////////////////////
918 /// Clear all navigators.
919 
921 {
923  TGeoNavigatorArray *arr = 0;
924  for (NavigatorsMap_t::iterator it = fNavigators.begin();
925  it != fNavigators.end(); it++) {
926  arr = (*it).second;
927  if (arr) delete arr;
928  }
929  fNavigators.clear();
931 }
932 
933 ////////////////////////////////////////////////////////////////////////////////
934 /// Clear a single navigator.
935 
937 {
939  for (NavigatorsMap_t::iterator it = fNavigators.begin();
940  it != fNavigators.end(); it++) {
941  TGeoNavigatorArray *arr = (*it).second;
942  if (arr) {
943  if ((TGeoNavigator*)arr->Remove((TObject*)nav)) {
944  delete nav;
945  if (!arr->GetEntries()) fNavigators.erase(it);
947  return;
948  }
949  }
950  }
951  Error("Remove navigator", "Navigator %p not found", nav);
953 }
954 
955 ////////////////////////////////////////////////////////////////////////////////
956 /// Set maximum number of threads for navigation.
957 
959 {
960  if (!fClosed) {
961  Error("SetMaxThreads", "Cannot set maximum number of threads before closing the geometry");
962  return;
963  }
964  if (!fMultiThread) {
966  Long_t threadId =TThread::SelfId();
967  NavigatorsMap_t::const_iterator it = fNavigators.find(0);
968  if (it != fNavigators.end()) {
969  TGeoNavigatorArray *array = it->second;
970  fNavigators.erase(it);
971  fNavigators.insert(NavigatorsMap_t::value_type(threadId, array));
972  }
973  }
974  if (fMaxThreads) {
975  ClearThreadsMap();
976  ClearThreadData();
977  }
978  fMaxThreads = nthreads+1;
979  if (fMaxThreads>0) {
982  }
983 }
984 
985 ////////////////////////////////////////////////////////////////////////////////
986 
988 {
989  if (!fMaxThreads) return;
990  TThread::Lock();
992  TGeoVolume *vol;
993  while ((vol=(TGeoVolume*)next())) vol->ClearThreadData();
994  TThread::UnLock();
995 }
996 
997 ////////////////////////////////////////////////////////////////////////////////
998 /// Create thread private data for all geometry objects.
999 
1001 {
1002  if (!fMaxThreads) return;
1003  TThread::Lock();
1004  TIter next(fVolumes);
1005  TGeoVolume *vol;
1006  while ((vol=(TGeoVolume*)next())) vol->CreateThreadData(fMaxThreads);
1007  TThread::UnLock();
1008 }
1009 
1010 ////////////////////////////////////////////////////////////////////////////////
1011 /// Clear the current map of threads. This will be filled again by the calling
1012 /// threads via ThreadId calls.
1013 
1015 {
1016  if (gGeoManager && !gGeoManager->IsMultiThread()) return;
1017  TThread::Lock();
1018  if (!fgThreadId->empty()) fgThreadId->clear();
1019  fgNumThreads = 0;
1020  TThread::UnLock();
1021 }
1022 
1023 ////////////////////////////////////////////////////////////////////////////////
1024 /// Translates the current thread id to an ordinal number. This can be used to
1025 /// manage data which is pspecific for a given thread.
1026 /// static __thread Int_t tid = -1;
1027 /// if (tid > -1) return tid;
1028 
1030 {
1031  TTHREAD_TLS(Int_t) tid = -1;
1032  Int_t ttid = tid; // TTHREAD_TLS_GET(Int_t,tid);
1033  if (ttid > -1) return ttid;
1034  if (gGeoManager && !gGeoManager->IsMultiThread()) return 0;
1036  if (it != fgThreadId->end()) return it->second;
1037  // Map needs to be updated.
1038  TThread::Lock();
1039  (*fgThreadId)[TThread::SelfId()] = fgNumThreads;
1040  tid = fgNumThreads; // TTHREAD_TLS_SET(Int_t,tid,fgNumThreads);
1041  ttid = fgNumThreads++;
1042  TThread::UnLock();
1043  return ttid;
1044 }
1045 
1046 ////////////////////////////////////////////////////////////////////////////////
1047 /// Describe how to browse this object.
1048 
1050 {
1051  if (!b) return;
1052  if (fMaterials) b->Add(fMaterials, "Materials");
1053  if (fMedia) b->Add(fMedia, "Media");
1054  if (fMatrices) b->Add(fMatrices, "Local transformations");
1055  if (fOverlaps) b->Add(fOverlaps, "Illegal overlaps");
1056  if (fTracks) b->Add(fTracks, "Tracks");
1057  if (fMasterVolume) b->Add(fMasterVolume, "Master Volume", fMasterVolume->IsVisible());
1058  if (fTopVolume) b->Add(fTopVolume, "Top Volume", fTopVolume->IsVisible());
1059  if (fTopNode) b->Add(fTopNode);
1060  TString browserImp(gEnv->GetValue("Browser.Name", "TRootBrowserLite"));
1061  TQObject::Connect(browserImp.Data(), "Checked(TObject*,Bool_t)",
1062  "TGeoManager", this, "SetVisibility(TObject*,Bool_t)");
1063 }
1064 
1065 ////////////////////////////////////////////////////////////////////////////////
1066 /// Append a pad for this geometry.
1067 
1069  AppendPad("");
1070  GetGeomPainter()->EditGeometry(option);
1071 }
1072 
1073 ////////////////////////////////////////////////////////////////////////////////
1074 /// Set visibility for a volume.
1075 
1077 {
1078  if(obj->IsA() == TGeoVolume::Class()) {
1079  TGeoVolume *vol = (TGeoVolume *) obj;
1080  vol->SetVisibility(vis);
1081  } else {
1082  if (obj->InheritsFrom(TGeoNode::Class())) {
1083  TGeoNode *node = (TGeoNode *) obj;
1084  node->SetVisibility(vis);
1085  } else return;
1086  }
1088 }
1089 
1090 ////////////////////////////////////////////////////////////////////////////////
1091 /// Get the new 'bombed' translation vector according current exploded view mode.
1092 
1094 {
1095  if (fPainter) fPainter->BombTranslation(tr, bombtr);
1096  return;
1097 }
1098 
1099 ////////////////////////////////////////////////////////////////////////////////
1100 /// Get the new 'unbombed' translation vector according current exploded view mode.
1101 
1103 {
1104  if (fPainter) fPainter->UnbombTranslation(tr, bombtr);
1105  return;
1106 }
1107 
1108 ////////////////////////////////////////////////////////////////////////////////
1109 /// Backup the current state without affecting the cache stack.
1110 
1112 {
1114 }
1115 
1116 ////////////////////////////////////////////////////////////////////////////////
1117 /// Restore a backed-up state without affecting the cache stack.
1118 
1120 {
1122 }
1123 
1124 ////////////////////////////////////////////////////////////////////////////////
1125 /// Register a matrix to the list of matrices. It will be cleaned-up at the
1126 /// destruction TGeoManager.
1127 
1129 {
1130  return TGeoBuilder::Instance(this)->RegisterMatrix((TGeoMatrix*)matrix);
1131 }
1132 
1133 ////////////////////////////////////////////////////////////////////////////////
1134 /// Replaces all occurences of VORIG with VNEW in the geometry tree. The volume VORIG
1135 /// is not replaced from the list of volumes, but all node referencing it will reference
1136 /// VNEW instead. Returns number of occurences changed.
1137 
1139 {
1140  Int_t nref = 0;
1141  if (!vorig || !vnew) return nref;
1142  TGeoMedium *morig = vorig->GetMedium();
1143  Bool_t checkmed = kFALSE;
1144  if (morig) checkmed = kTRUE;
1145  TGeoMedium *mnew = vnew->GetMedium();
1146  // Try to limit the damage produced by incorrect usage.
1147  if (!mnew && !vnew->IsAssembly()) {
1148  Error("ReplaceVolume","Replacement volume %s has no medium and it is not an assembly",
1149  vnew->GetName());
1150  return nref;
1151  }
1152  if (mnew && checkmed) {
1153  if (mnew->GetId() != morig->GetId())
1154  Warning("ReplaceVolume","Replacement volume %s has different medium than original volume %s",
1155  vnew->GetName(), vorig->GetName());
1156  checkmed = kFALSE;
1157  }
1158 
1159  // Medium checking now performed only if replacement is an assembly and old volume a real one.
1160  // Check result is dependent on positioning.
1161  Int_t nvol = fVolumes->GetEntriesFast();
1162  Int_t i,j,nd;
1163  Int_t ierr = 0;
1164  TGeoVolume *vol;
1165  TGeoNode *node;
1166  TGeoVoxelFinder *voxels;
1167  for (i=0; i<nvol; i++) {
1168  vol = (TGeoVolume*)fVolumes->At(i);
1169  if (!vol) continue;
1170  if (vol==vorig || vol==vnew) continue;
1171  nd = vol->GetNdaughters();
1172  for (j=0; j<nd; j++) {
1173  node = vol->GetNode(j);
1174  if (node->GetVolume() == vorig) {
1175  if (checkmed) {
1176  mnew = node->GetMotherVolume()->GetMedium();
1177  if (mnew && mnew->GetId()!=morig->GetId()) ierr++;
1178  }
1179  nref++;
1180  if (node->IsOverlapping()) {
1181  node->SetOverlapping(kFALSE);
1182  Info("ReplaceVolume","%s replaced with assembly and declared NON-OVERLAPPING!",node->GetName());
1183  }
1184  node->SetVolume(vnew);
1185  voxels = node->GetMotherVolume()->GetVoxels();
1186  if (voxels) voxels->SetNeedRebuild();
1187  } else {
1188  if (node->GetMotherVolume() == vorig) {
1189  nref++;
1190  node->SetMotherVolume(vnew);
1191  if (node->IsOverlapping()) {
1192  node->SetOverlapping(kFALSE);
1193  Info("ReplaceVolume","%s inside substitute assembly %s declared NON-OVERLAPPING!",node->GetName(),vnew->GetName());
1194  }
1195  }
1196  }
1197  }
1198  }
1199  if (ierr) Warning("ReplaceVolume", "Volumes should not be replaced with assemblies if they are positioned in containers having a different medium ID.\n %i occurences for assembly replacing volume %s",
1200  ierr, vorig->GetName());
1201  return nref;
1202 }
1203 
1204 ////////////////////////////////////////////////////////////////////////////////
1205 /// Transform all volumes named VNAME to assemblies. The volumes must be virtual.
1206 
1208 {
1209  TGeoVolume *toTransform = FindVolumeFast(vname);
1210  if (!toTransform) {
1211  Warning("TransformVolumeToAssembly", "Volume %s not found", vname);
1212  return 0;
1213  }
1214  Int_t index = fVolumes->IndexOf(toTransform);
1215  Int_t count = 0;
1216  Int_t indmax = fVolumes->GetEntries();
1217  Bool_t replace = kTRUE;
1218  TGeoVolume *transformed;
1219  while (index<indmax) {
1220  if (replace) {
1221  replace = kFALSE;
1222  transformed = TGeoVolumeAssembly::MakeAssemblyFromVolume(toTransform);
1223  if (transformed) {
1224  ReplaceVolume(toTransform, transformed);
1225  count++;
1226  } else {
1227  if (toTransform->IsAssembly())
1228  Warning("TransformVolumeToAssembly", "Volume %s already assembly", toTransform->GetName());
1229  if (!toTransform->GetNdaughters())
1230  Warning("TransformVolumeToAssembly", "Volume %s has no daughters, cannot transform", toTransform->GetName());
1231  if (toTransform->IsVolumeMulti())
1232  Warning("TransformVolumeToAssembly", "Volume %s divided, cannot transform", toTransform->GetName());
1233  }
1234  }
1235  index++;
1236  if (index >= indmax) return count;
1237  toTransform = (TGeoVolume*)fVolumes->At(index);
1238  if (!strcmp(toTransform->GetName(),vname)) replace = kTRUE;
1239  }
1240  return count;
1241 }
1242 
1243 ////////////////////////////////////////////////////////////////////////////////
1244 /// Create a new volume by dividing an existing one (GEANT3 like)
1245 ///
1246 /// Divides MOTHER into NDIV divisions called NAME
1247 /// along axis IAXIS starting at coordinate value START
1248 /// and having size STEP. The created volumes will have tracking
1249 /// media ID=NUMED (if NUMED=0 -> same media as MOTHER)
1250 /// The behavior of the division operation can be triggered using OPTION :
1251 /// OPTION (case insensitive) :
1252 /// N - divide all range in NDIV cells (same effect as STEP<=0) (GSDVN in G3)
1253 /// NX - divide range starting with START in NDIV cells (GSDVN2 in G3)
1254 /// S - divide all range with given STEP. NDIV is computed and divisions will be centered
1255 /// in full range (same effect as NDIV<=0) (GSDVS, GSDVT in G3)
1256 /// SX - same as DVS, but from START position. (GSDVS2, GSDVT2 in G3)
1257 
1258 TGeoVolume *TGeoManager::Division(const char *name, const char *mother, Int_t iaxis,
1259  Int_t ndiv, Double_t start, Double_t step, Int_t numed, Option_t *option)
1260 {
1261  return TGeoBuilder::Instance(this)->Division(name, mother, iaxis, ndiv, start, step, numed, option);
1262 }
1263 
1264 ////////////////////////////////////////////////////////////////////////////////
1265 /// Create rotation matrix named 'mat<index>'.
1266 ///
1267 /// index rotation matrix number
1268 /// theta1 polar angle for axis X
1269 /// phi1 azimuthal angle for axis X
1270 /// theta2 polar angle for axis Y
1271 /// phi2 azimuthal angle for axis Y
1272 /// theta3 polar angle for axis Z
1273 /// phi3 azimuthal angle for axis Z
1274 ///
1275 
1276 void TGeoManager::Matrix(Int_t index, Double_t theta1, Double_t phi1,
1277  Double_t theta2, Double_t phi2,
1278  Double_t theta3, Double_t phi3)
1279 {
1280  TGeoBuilder::Instance(this)->Matrix(index, theta1, phi1, theta2, phi2, theta3, phi3);
1281 }
1282 
1283 ////////////////////////////////////////////////////////////////////////////////
1284 /// Create material with given A, Z and density, having an unique id.
1285 
1287 {
1288  return TGeoBuilder::Instance(this)->Material(name, a, z, dens, uid, radlen, intlen);
1289 
1290 }
1291 
1292 ////////////////////////////////////////////////////////////////////////////////
1293 /// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1294 /// materials defined by arrays A,Z and WMAT, having an unique id.
1295 
1297  Int_t nelem, Float_t *wmat, Int_t uid)
1298 {
1299  return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1300 }
1301 
1302 ////////////////////////////////////////////////////////////////////////////////
1303 /// Create mixture OR COMPOUND IMAT as composed by THE BASIC nelem
1304 /// materials defined by arrays A,Z and WMAT, having an unique id.
1305 
1307  Int_t nelem, Double_t *wmat, Int_t uid)
1308 {
1309  return TGeoBuilder::Instance(this)->Mixture(name, a, z, dens, nelem, wmat, uid);
1310 }
1311 
1312 ////////////////////////////////////////////////////////////////////////////////
1313 /// Create tracking medium
1314 ///
1315 /// numed tracking medium number assigned
1316 /// name tracking medium name
1317 /// nmat material number
1318 /// isvol sensitive volume flag
1319 /// ifield magnetic field
1320 /// fieldm max. field value (kilogauss)
1321 /// tmaxfd max. angle due to field (deg/step)
1322 /// stemax max. step allowed
1323 /// deemax max. fraction of energy lost in a step
1324 /// epsil tracking precision (cm)
1325 /// stmin min. step due to continuous processes (cm)
1326 ///
1327 /// ifield = 0 if no magnetic field; ifield = -1 if user decision in guswim;
1328 /// ifield = 1 if tracking performed with g3rkuta; ifield = 2 if tracking
1329 /// performed with g3helix; ifield = 3 if tracking performed with g3helx3.
1330 ///
1331 
1332 TGeoMedium *TGeoManager::Medium(const char *name, Int_t numed, Int_t nmat, Int_t isvol,
1333  Int_t ifield, Double_t fieldm, Double_t tmaxfd,
1334  Double_t stemax, Double_t deemax, Double_t epsil,
1335  Double_t stmin)
1336 {
1337  return TGeoBuilder::Instance(this)->Medium(name, numed, nmat, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
1338 }
1339 
1340 ////////////////////////////////////////////////////////////////////////////////
1341 /// Create a node called <name_nr> pointing to the volume called <name>
1342 /// as daughter of the volume called <mother> (gspos). The relative matrix is
1343 /// made of : a translation (x,y,z) and a rotation matrix named <matIROT>.
1344 /// In case npar>0, create the volume to be positioned in mother, according
1345 /// its actual parameters (gsposp).
1346 /// NAME Volume name
1347 /// NUMBER Copy number of the volume
1348 /// MOTHER Mother volume name
1349 /// X X coord. of the volume in mother ref. sys.
1350 /// Y Y coord. of the volume in mother ref. sys.
1351 /// Z Z coord. of the volume in mother ref. sys.
1352 /// IROT Rotation matrix number w.r.t. mother ref. sys.
1353 /// ISONLY ONLY/MANY flag
1354 
1355 void TGeoManager::Node(const char *name, Int_t nr, const char *mother,
1356  Double_t x, Double_t y, Double_t z, Int_t irot,
1357  Bool_t isOnly, Float_t *upar, Int_t npar)
1358 {
1359  TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1360 }
1361 
1362 ////////////////////////////////////////////////////////////////////////////////
1363 /// Create a node called <name_nr> pointing to the volume called <name>
1364 /// as daughter of the volume called <mother> (gspos). The relative matrix is
1365 /// made of : a translation (x,y,z) and a rotation matrix named <matIROT>.
1366 /// In case npar>0, create the volume to be positioned in mother, according
1367 /// its actual parameters (gsposp).
1368 /// NAME Volume name
1369 /// NUMBER Copy number of the volume
1370 /// MOTHER Mother volume name
1371 /// X X coord. of the volume in mother ref. sys.
1372 /// Y Y coord. of the volume in mother ref. sys.
1373 /// Z Z coord. of the volume in mother ref. sys.
1374 /// IROT Rotation matrix number w.r.t. mother ref. sys.
1375 /// ISONLY ONLY/MANY flag
1376 
1377 void TGeoManager::Node(const char *name, Int_t nr, const char *mother,
1378  Double_t x, Double_t y, Double_t z, Int_t irot,
1379  Bool_t isOnly, Double_t *upar, Int_t npar)
1380 {
1381  TGeoBuilder::Instance(this)->Node(name, nr, mother, x, y, z, irot, isOnly, upar, npar);
1382 
1383 }
1384 
1385 ////////////////////////////////////////////////////////////////////////////////
1386 /// Create a volume in GEANT3 style.
1387 /// NAME Volume name
1388 /// SHAPE Volume type
1389 /// NMED Tracking medium number
1390 /// NPAR Number of shape parameters
1391 /// UPAR Vector containing shape parameters
1392 
1393 TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed,
1394  Float_t *upar, Int_t npar)
1395 {
1396  return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1397 }
1398 
1399 ////////////////////////////////////////////////////////////////////////////////
1400 /// Create a volume in GEANT3 style.
1401 /// NAME Volume name
1402 /// SHAPE Volume type
1403 /// NMED Tracking medium number
1404 /// NPAR Number of shape parameters
1405 /// UPAR Vector containing shape parameters
1406 
1407 TGeoVolume *TGeoManager::Volume(const char *name, const char *shape, Int_t nmed,
1408  Double_t *upar, Int_t npar)
1409 {
1410  return TGeoBuilder::Instance(this)->Volume(name, shape, nmed, upar, npar);
1411 }
1412 
1413 ////////////////////////////////////////////////////////////////////////////////
1414 /// Assigns uid's for all materials,media and matrices.
1415 
1417 {
1418  Int_t index = 1;
1420  TGeoMaterial *mater;
1421  while ((mater=(TGeoMaterial*)next())) {
1422  mater->SetUniqueID(index++);
1424  }
1425  index = 1;
1426  TIter next1(fMedia);
1427  TGeoMedium *med;
1428  while ((med=(TGeoMedium*)next1())) {
1429  med->SetUniqueID(index++);
1431  }
1432  index = 1;
1433  TIter next2(fShapes);
1434  TGeoShape *shape;
1435  while ((shape=(TGeoShape*)next2())) {
1436  shape->SetUniqueID(index++);
1437  if (shape->IsComposite()) ((TGeoCompositeShape*)shape)->GetBoolNode()->RegisterMatrices();
1438  }
1439 
1440  TIter next3(fMatrices);
1441  TGeoMatrix *matrix;
1442  while ((matrix=(TGeoMatrix*)next3())) {
1443  matrix->RegisterYourself();
1444  }
1445  TIter next4(fMatrices);
1446  index = 1;
1447  while ((matrix=(TGeoMatrix*)next4())) {
1448  matrix->SetUniqueID(index++);
1450  }
1451  TIter next5(fVolumes);
1452  TGeoVolume *vol;
1453  while ((vol=(TGeoVolume*)next5())) vol->UnmarkSaved();
1454 }
1455 
1456 ////////////////////////////////////////////////////////////////////////////////
1457 /// Reset all attributes to default ones. Default attributes for visualization
1458 /// are those defined before closing the geometry.
1459 
1461 {
1462  if (gPad) delete gPad;
1463  gPad = 0;
1464  SetVisOption(0);
1465  SetVisLevel(3);
1466  SetExplodedView(0);
1467  SetBombFactors();
1468  if (!gStyle) return;
1469  TIter next(fVolumes);
1470  TGeoVolume *vol = 0;
1471  while ((vol=(TGeoVolume*)next())) {
1472  if (!vol->IsVisTouched()) continue;
1473  vol->SetVisTouched(kFALSE);
1474  }
1475 }
1476 ////////////////////////////////////////////////////////////////////////////////
1477 /// Closing geometry implies checking the geometry validity, fixing shapes
1478 /// with negative parameters (run-time shapes)building the cache manager,
1479 /// voxelizing all volumes, counting the total number of physical nodes and
1480 /// registring the manager class to the browser.
1481 
1483 {
1484  if (fClosed) {
1485  Warning("CloseGeometry", "geometry already closed");
1486  return;
1487  }
1488  if (!fMasterVolume) {
1489  Error("CloseGeometry","you MUST call SetTopVolume() first !");
1490  return;
1491  }
1492  if (!gROOT->GetListOfGeometries()->FindObject(this)) gROOT->GetListOfGeometries()->Add(this);
1493  if (!gROOT->GetListOfBrowsables()->FindObject(this)) gROOT->GetListOfBrowsables()->Add(this);
1494 // TSeqCollection *brlist = gROOT->GetListOfBrowsers();
1495 // TIter next(brlist);
1496 // TBrowser *browser = 0;
1497 // while ((browser=(TBrowser*)next())) browser->Refresh();
1498  TString opt(option);
1499  opt.ToLower();
1500 // Bool_t dummy = opt.Contains("d");
1501  Bool_t nodeid = opt.Contains("i");
1502  // Create a geometry navigator if not present
1503  TGeoNavigator *nav = 0;
1504  Int_t nnavigators = 0;
1505  // Check if the geometry is streamed from file
1506  if (fIsGeomReading) {
1507  if (fgVerboseLevel>0) Info("CloseGeometry","Geometry loaded from file...");
1509  if (!fElementTable) fElementTable = new TGeoElementTable(200);
1510  if (!fTopNode) {
1511  if (!fMasterVolume) {
1512  Error("CloseGeometry", "Master volume not streamed");
1513  return;
1514  }
1516  if (fStreamVoxels && fgVerboseLevel>0) Info("CloseGeometry","Voxelization retrieved from file");
1517  }
1518  // Create a geometry navigator if not present
1520  nnavigators = GetListOfNavigators()->GetEntriesFast();
1521  TIter next(fShapes);
1522  TGeoShape *shape;
1523  while ((shape = (TGeoShape*)next())) shape->AfterStreamer();
1524  Voxelize("ALL");
1525  CountLevels();
1526  for (Int_t i=0; i<nnavigators; i++) {
1527  nav = (TGeoNavigator*)GetListOfNavigators()->At(i);
1528  nav->GetCache()->BuildInfoBranch();
1529  if (nodeid) nav->GetCache()->BuildIdArray();
1530  }
1531  if (!fHashVolumes) {
1532  Int_t nvol = fVolumes->GetEntriesFast();
1533  Int_t ngvol = fGVolumes->GetEntriesFast();
1534  fHashVolumes = new THashList(nvol+1);
1535  fHashGVolumes = new THashList(ngvol+1);
1536  Int_t i;
1537  for (i=0; i<ngvol; i++) fHashGVolumes->AddLast(fGVolumes->At(i));
1538  for (i=0; i<nvol; i++) fHashVolumes->AddLast(fVolumes->At(i));
1539  }
1540  fClosed = kTRUE;
1541  if (fParallelWorld) {
1542  if (fgVerboseLevel>0) Info("CloseGeometry","Recreating parallel world %s ...",fParallelWorld->GetName());
1544  }
1545 
1546  if (fgVerboseLevel>0) Info("CloseGeometry","%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast()-1, GetTitle());
1547  if (fgVerboseLevel>0) Info("CloseGeometry","----------------modeler ready----------------");
1548  return;
1549  }
1550 
1551  // Create a geometry navigator if not present
1553  nnavigators = GetListOfNavigators()->GetEntriesFast();
1555  CheckGeometry();
1556  if (fgVerboseLevel>0) Info("CloseGeometry","Counting nodes...");
1557  fNNodes = CountNodes();
1558  fNLevel = fMasterVolume->CountNodes(1,3)+1;
1559  if (fNLevel<30) fNLevel = 100;
1560 
1561 // BuildIdArray();
1562  Voxelize("ALL");
1563  if (fgVerboseLevel>0) Info("CloseGeometry","Building cache...");
1564  CountLevels();
1565  for (Int_t i=0; i<nnavigators; i++) {
1566  nav = (TGeoNavigator*)GetListOfNavigators()->At(i);
1567  nav->GetCache()->BuildInfoBranch();
1568  if (nodeid) nav->GetCache()->BuildIdArray();
1569  }
1570  fClosed = kTRUE;
1571  if (fgVerboseLevel>0) {
1572  Info("CloseGeometry","%i nodes/ %i volume UID's in %s", fNNodes, fUniqueVolumes->GetEntriesFast()-1, GetTitle());
1573  Info("CloseGeometry","----------------modeler ready----------------");
1574  }
1575 }
1576 
1577 ////////////////////////////////////////////////////////////////////////////////
1578 /// Clear the list of overlaps.
1579 
1581 {
1582  if (fOverlaps) {
1583  fOverlaps->Delete();
1584  delete fOverlaps;
1585  }
1586  fOverlaps = new TObjArray();
1587 }
1588 
1589 ////////////////////////////////////////////////////////////////////////////////
1590 /// Remove a shape from the list of shapes.
1591 
1593 {
1594  if (fShapes->FindObject(shape)) fShapes->Remove((TGeoShape*)shape);
1595  delete shape;
1596 }
1597 ////////////////////////////////////////////////////////////////////////////////
1598 /// Clean temporary volumes and shapes from garbage collection.
1599 
1601 {
1602  if (!fGVolumes && !fGShapes) return;
1603  Int_t i,nentries;
1604  if (fGVolumes) {
1605  nentries = fGVolumes->GetEntries();
1606  TGeoVolume *vol = 0;
1607  for (i=0; i<nentries; i++) {
1608  vol=(TGeoVolume*)fGVolumes->At(i);
1609  if (vol) vol->SetFinder(0);
1610  }
1611  fGVolumes->Delete();
1612  delete fGVolumes;
1613  fGVolumes = 0;
1614  }
1615  if (fGShapes) {
1616  fGShapes->Delete();
1617  delete fGShapes;
1618  fGShapes = 0;
1619  }
1620 }
1621 
1622 ////////////////////////////////////////////////////////////////////////////////
1623 /// Change current path to point to the node having this id.
1624 /// Node id has to be in range : 0 to fNNodes-1 (no check for performance reasons)
1625 
1627 {
1628  GetCurrentNavigator()->CdNode(nodeid);
1629 }
1630 
1631 ////////////////////////////////////////////////////////////////////////////////
1632 /// Get the unique ID of the current node.
1633 
1635 {
1637 }
1638 
1639 ////////////////////////////////////////////////////////////////////////////////
1640 /// Make top level node the current node. Updates the cache accordingly.
1641 /// Determine the overlapping state of current node.
1642 
1644 {
1646 }
1647 
1648 ////////////////////////////////////////////////////////////////////////////////
1649 /// Go one level up in geometry. Updates cache accordingly.
1650 /// Determine the overlapping state of current node.
1651 
1653 {
1655 }
1656 ////////////////////////////////////////////////////////////////////////////////
1657 /// Make a daughter of current node current. Can be called only with a valid
1658 /// daughter index (no check). Updates cache accordingly.
1659 
1661 {
1662  GetCurrentNavigator()->CdDown(index);
1663 }
1664 
1665 ////////////////////////////////////////////////////////////////////////////////
1666 /// Do a cd to the node found next by FindNextBoundary
1667 
1669 {
1671 }
1672 
1673 ////////////////////////////////////////////////////////////////////////////////
1674 /// Browse the tree of nodes starting from fTopNode according to pathname.
1675 /// Changes the path accordingly.
1676 
1677 Bool_t TGeoManager::cd(const char *path)
1678 {
1679  return GetCurrentNavigator()->cd(path);
1680 }
1681 
1682 ////////////////////////////////////////////////////////////////////////////////
1683 /// Check if a geometry path is valid without changing the state of the current navigator.
1684 
1685 Bool_t TGeoManager::CheckPath(const char *path) const
1686 {
1687  return GetCurrentNavigator()->CheckPath(path);
1688 }
1689 
1690 ////////////////////////////////////////////////////////////////////////////////
1691 /// Convert all reflections in geometry to normal rotations + reflected shapes.
1692 
1694 {
1695  if (!fTopNode) return;
1696  if (fgVerboseLevel>0) Info("ConvertReflections", "Converting reflections in: %s - %s ...", GetName(), GetTitle());
1698  TGeoNode *node;
1699  TGeoNodeMatrix *nodematrix;
1700  TGeoMatrix *matrix, *mclone;
1701  TGeoVolume *reflected;
1702  while ((node=next())) {
1703  matrix = node->GetMatrix();
1704  if (matrix->IsReflection()) {
1705 // printf("%s before\n", node->GetName());
1706 // matrix->Print();
1707  mclone = new TGeoCombiTrans(*matrix);
1708  mclone->RegisterYourself();
1709  // Reflect just the rotation component
1710  mclone->ReflectZ(kFALSE, kTRUE);
1711  nodematrix = (TGeoNodeMatrix*)node;
1712  nodematrix->SetMatrix(mclone);
1713 // printf("%s after\n", node->GetName());
1714 // node->GetMatrix()->Print();
1715  reflected = node->GetVolume()->MakeReflectedVolume();
1716  node->SetVolume(reflected);
1717  }
1718  }
1719  if (fgVerboseLevel>0) Info("ConvertReflections", "Done");
1720 }
1721 
1722 ////////////////////////////////////////////////////////////////////////////////
1723 /// Count maximum number of nodes per volume, maximum depth and maximum
1724 /// number of xtru vertices.
1725 
1727 {
1728  if (!fTopNode) {
1729  Error("CountLevels", "Top node not defined.");
1730  return;
1731  }
1733  Bool_t fixrefs = fIsGeomReading && (fMasterVolume->GetRefCount()==1);
1735  if (fgVerboseLevel>1 && fixrefs) Info("CountLevels", "Fixing volume reference counts");
1736  TGeoNode *node;
1737  Int_t maxlevel = 1;
1738  Int_t maxnodes = fTopVolume->GetNdaughters();
1739  Int_t maxvertices = 1;
1740  while ((node=next())) {
1741  if (fixrefs) {
1742  node->GetVolume()->Grab();
1743  for (Int_t ibit=10; ibit<14; ibit++) {
1744  node->SetBit(BIT(ibit+4), node->TestBit(BIT(ibit)));
1745 // node->ResetBit(BIT(ibit)); // cannot overwrite old crap for reproducibility
1746  }
1747  }
1748  if (node->GetVolume()->GetVoxels()) {
1749  if (node->GetNdaughters()>maxnodes) maxnodes = node->GetNdaughters();
1750  }
1751  if (next.GetLevel()>maxlevel) maxlevel = next.GetLevel();
1752  if (node->GetVolume()->GetShape()->IsA()==TGeoXtru::Class()) {
1753  TGeoXtru *xtru = (TGeoXtru*)node->GetVolume()->GetShape();
1754  if (xtru->GetNvert()>maxvertices) maxvertices = xtru->GetNvert();
1755  }
1756  }
1757  fgMaxLevel = maxlevel;
1758  fgMaxDaughters = maxnodes;
1759  fgMaxXtruVert = maxvertices;
1760  if (fgVerboseLevel>0) Info("CountLevels", "max level = %d, max placements = %d", fgMaxLevel, fgMaxDaughters);
1761 }
1762 
1763 ////////////////////////////////////////////////////////////////////////////////
1764 /// Count the total number of nodes starting from a volume, nlevels down.
1765 
1767 {
1768  TGeoVolume *top;
1769  if (!vol) {
1770  top = fTopVolume;
1771  } else {
1772  top = (TGeoVolume*)vol;
1773  }
1774  Int_t count = top->CountNodes(nlevels, option);
1775  return count;
1776 }
1777 
1778 ////////////////////////////////////////////////////////////////////////////////
1779 /// Set default angles for a given view.
1780 
1782 {
1784 }
1785 
1786 ////////////////////////////////////////////////////////////////////////////////
1787 /// Draw current point in the same view.
1788 
1790 {
1791  if (fPainter) fPainter->DrawCurrentPoint(color);
1792 }
1793 
1794 ////////////////////////////////////////////////////////////////////////////////
1795 /// Draw animation of tracks
1796 
1797 void TGeoManager::AnimateTracks(Double_t tmin, Double_t tmax, Int_t nframes, Option_t *option)
1798 {
1799  SetAnimateTracks();
1800  GetGeomPainter();
1801  if (tmin<0 || tmin>=tmax || nframes<1) return;
1803  box[0] = box[1] = box[2] = 0;
1804  box[3] = box[4] = box[5] = 100;
1805  Double_t dt = (tmax-tmin)/Double_t(nframes);
1806  Double_t delt = 2E-9;
1807  Double_t t = tmin;
1808  Int_t i, j;
1809  TString opt(option);
1810  Bool_t save = kFALSE, geomanim=kFALSE;
1811  TString fname;
1812  if (opt.Contains("/S")) save = kTRUE;
1813 
1814  if (opt.Contains("/G")) geomanim = kTRUE;
1815  SetTminTmax(0,0);
1816  DrawTracks(opt.Data());
1817  Double_t start[6], end[6];
1818  Double_t dd[6] = {0,0,0,0,0,0};
1819  Double_t dlat=0, dlong=0, dpsi=0;
1820  if (geomanim) {
1821  fPainter->EstimateCameraMove(tmin+5*dt, tmin+15*dt, start, end);
1822  for (i=0; i<3; i++) {
1823  start[i+3] = 20 + 1.3*start[i+3];
1824  end[i+3] = 20 + 0.9*end[i+3];
1825  }
1826  for (i=0; i<6; i++) {
1827  dd[i] = (end[i]-start[i])/10.;
1828  }
1829  memcpy(box, start, 6*sizeof(Double_t));
1830  fPainter->GetViewAngles(dlong,dlat,dpsi);
1831  dlong = (-206-dlong)/Double_t(nframes);
1832  dlat = (126-dlat)/Double_t(nframes);
1833  dpsi = (75-dpsi)/Double_t(nframes);
1834  fPainter->GrabFocus();
1835  }
1836 
1837  for (i=0; i<nframes; i++) {
1838  if (t-delt<0) SetTminTmax(t-delt,t);
1839  else gGeoManager->SetTminTmax(t-delt,t);
1840  if (geomanim) {
1841  for (j=0; j<6; j++) box[j]+=dd[j];
1842  fPainter->GrabFocus(1,dlong,dlat,dpsi);
1843  } else {
1844  ModifiedPad();
1845  }
1846  if (save) {
1847  fname = TString::Format("anim%04d.gif", i);
1848  gPad->Print(fname);
1849  }
1850  t += dt;
1851  }
1853 }
1854 
1855 ////////////////////////////////////////////////////////////////////////////////
1856 /// Draw tracks over the geometry, according to option. By default, only
1857 /// primaries are drawn. See TGeoTrack::Draw() for additional options.
1858 
1860 {
1861  TVirtualGeoTrack *track;
1862  //SetVisLevel(1);
1863  //SetVisOption(1);
1864  SetAnimateTracks();
1865  for (Int_t i=0; i<fNtracks; i++) {
1866  track = GetTrack(i);
1867  if (track) track->Draw(option);
1868  }
1870  ModifiedPad();
1871 }
1872 
1873 ////////////////////////////////////////////////////////////////////////////////
1874 /// Draw current path
1875 
1876 void TGeoManager::DrawPath(const char *path, Option_t *option)
1877 {
1878  if (!fTopVolume) return;
1880  GetGeomPainter()->DrawPath(path, option);
1881 }
1882 ////////////////////////////////////////////////////////////////////////////////
1883 /// Draw random points in the bounding box of a volume.
1884 
1885 void TGeoManager::RandomPoints(const TGeoVolume *vol, Int_t npoints, Option_t *option)
1886 {
1887  GetGeomPainter()->RandomPoints((TGeoVolume*)vol, npoints, option);
1888 }
1889 ////////////////////////////////////////////////////////////////////////////////
1890 /// Check time of finding "Where am I" for n points.
1891 
1892 void TGeoManager::Test(Int_t npoints, Option_t *option)
1893 {
1894  GetGeomPainter()->Test(npoints, option);
1895 }
1896 ////////////////////////////////////////////////////////////////////////////////
1897 /// Geometry overlap checker based on sampling.
1898 
1899 void TGeoManager::TestOverlaps(const char* path)
1900 {
1901  GetGeomPainter()->TestOverlaps(path);
1902 }
1903 ////////////////////////////////////////////////////////////////////////////////
1904 /// Fill volume names of current branch into an array.
1905 
1907 {
1909 }
1910 ////////////////////////////////////////////////////////////////////////////////
1911 /// Get name for given pdg code;
1912 
1913 const char *TGeoManager::GetPdgName(Int_t pdg) const
1914 {
1915  static char defaultname[5] = { "XXX" };
1916  if (!fPdgNames || !pdg) return defaultname;
1917  for (Int_t i=0; i<fNpdg; i++) {
1918  if (fPdgId[i]==pdg) return fPdgNames->At(i)->GetName();
1919  }
1920  return defaultname;
1921 }
1922 
1923 ////////////////////////////////////////////////////////////////////////////////
1924 /// Set a name for a particle having a given pdg.
1925 
1926 void TGeoManager::SetPdgName(Int_t pdg, const char *name)
1927 {
1928  if (!pdg) return;
1929  if (!fPdgNames) {
1930  fPdgNames = new TObjArray(1024);
1931  }
1932  if (!strcmp(name, GetPdgName(pdg))) return;
1933  // store pdg name
1934  if (fNpdg>1023) {
1935  Warning("SetPdgName", "No more than 256 different pdg codes allowed");
1936  return;
1937  }
1938  fPdgId[fNpdg] = pdg;
1939  TNamed *pdgname = new TNamed(name, "");
1940  fPdgNames->AddAtAndExpand(pdgname, fNpdg++);
1941 }
1942 
1943 ////////////////////////////////////////////////////////////////////////////////
1944 /// Fill node copy numbers of current branch into an array.
1945 
1946 void TGeoManager::GetBranchNumbers(Int_t *copyNumbers, Int_t *volumeNumbers) const
1947 {
1948  GetCurrentNavigator()->GetBranchNumbers(copyNumbers, volumeNumbers);
1949 }
1950 
1951 ////////////////////////////////////////////////////////////////////////////////
1952 /// Fill node copy numbers of current branch into an array.
1953 
1955 {
1957 }
1958 
1959 ////////////////////////////////////////////////////////////////////////////////
1960 /// Retrieve cartesian and radial bomb factors.
1961 
1962 void TGeoManager::GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const
1963 {
1964  if (fPainter) {
1965  fPainter->GetBombFactors(bombx, bomby, bombz, bombr);
1966  return;
1967  }
1968  bombx = bomby = bombz = bombr = 1.3;
1969 }
1970 
1971 ////////////////////////////////////////////////////////////////////////////////
1972 /// Return maximum number of daughters of a volume used in the geometry.
1973 
1975 {
1976  return fgMaxDaughters;
1977 }
1978 
1979 ////////////////////////////////////////////////////////////////////////////////
1980 /// Return maximum number of levels used in the geometry.
1981 
1983 {
1984  return fgMaxLevel;
1985 }
1986 
1987 ////////////////////////////////////////////////////////////////////////////////
1988 /// Return maximum number of vertices for an xtru shape used.
1989 
1991 {
1992  return fgMaxXtruVert;
1993 }
1994 
1995 ////////////////////////////////////////////////////////////////////////////////
1996 /// Returns number of threads that were set to use geometry.
1997 
1999 {
2000  return fgNumThreads;
2001 }
2002 
2003 ////////////////////////////////////////////////////////////////////////////////
2004 /// Return stored current matrix (global matrix of the next touched node).
2005 
2007 {
2008  if (!GetCurrentNavigator()) return NULL;
2009  return GetCurrentNavigator()->GetHMatrix();
2010 }
2011 
2012 ////////////////////////////////////////////////////////////////////////////////
2013 /// Returns current depth to which geometry is drawn.
2014 
2016 {
2017  return fVisLevel;
2018 }
2019 
2020 ////////////////////////////////////////////////////////////////////////////////
2021 /// Returns current depth to which geometry is drawn.
2022 
2024 {
2025  return fVisOption;
2026 }
2027 
2028 ////////////////////////////////////////////////////////////////////////////////
2029 /// Find level of virtuality of current overlapping node (number of levels
2030 /// up having the same tracking media.
2031 
2033 {
2035 }
2036 ////////////////////////////////////////////////////////////////////////////////
2037 /// Search the track hierarchy to find the track with the
2038 /// given id
2039 ///
2040 /// if 'primsFirst' is true, then:
2041 /// first tries TGeoManager::GetTrackOfId, then does a
2042 /// recursive search if that fails. this would be faster
2043 /// if the track is somehow known to be a primary
2044 
2046 {
2047  TVirtualGeoTrack* trk = 0;
2048  trk = GetTrackOfId(id);
2049  if (trk) return trk;
2050  // need recursive search
2051  TIter next(fTracks);
2052  TVirtualGeoTrack* prim;
2053  while ((prim = (TVirtualGeoTrack*)next())) {
2054  trk = prim->FindTrackWithId(id);
2055  if (trk) return trk;
2056  }
2057  return NULL;
2058 }
2059 
2060 ////////////////////////////////////////////////////////////////////////////////
2061 /// Get track with a given ID.
2062 
2064 {
2065  TVirtualGeoTrack *track;
2066  for (Int_t i=0; i<fNtracks; i++) {
2067  if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2068  if (track->GetId() == id) return track;
2069  }
2070  }
2071  return 0;
2072 }
2073 
2074 ////////////////////////////////////////////////////////////////////////////////
2075 /// Get parent track with a given ID.
2076 
2078 {
2080  while ((track=track->GetMother())) {
2081  if (track->GetId()==id) return track;
2082  }
2083  return 0;
2084 }
2085 
2086 ////////////////////////////////////////////////////////////////////////////////
2087 /// Get index for track id, -1 if not found.
2088 
2090 {
2091  TVirtualGeoTrack *track;
2092  for (Int_t i=0; i<fNtracks; i++) {
2093  if ((track = (TVirtualGeoTrack *)fTracks->UncheckedAt(i))) {
2094  if (track->GetId() == id) return i;
2095  }
2096  }
2097  return -1;
2098 }
2099 
2100 ////////////////////////////////////////////////////////////////////////////////
2101 /// Go upwards the tree until a non-overlaping node
2102 
2104 {
2105  return GetCurrentNavigator()->GotoSafeLevel();
2106 }
2107 
2108 ////////////////////////////////////////////////////////////////////////////////
2109 /// Go upwards the tree until a non-overlaping node
2110 
2112 {
2113  return GetCurrentNavigator()->GetSafeLevel();
2114 }
2115 
2116 ////////////////////////////////////////////////////////////////////////////////
2117 /// Set default volume colors according to A of material
2118 
2120 {
2121  const Int_t nmax = 110;
2122  Int_t col[nmax];
2123  for (Int_t i=0;i<nmax;i++) col[i] = kGray;
2124 
2125  //here we should create a new TColor with the same rgb as in the default
2126  //ROOT colors used below
2127  col[ 3] = kYellow-10;
2128  col[ 4] = col[ 5] = kGreen-10;
2129  col[ 6] = col[ 7] = kBlue-7;
2130  col[ 8] = col[ 9] = kMagenta-3;
2131  col[10] = col[11] = kRed-10;
2132  col[12] = kGray+1;
2133  col[13] = kBlue-10;
2134  col[14] = kOrange+7;
2135  col[16] = kYellow+1;
2136  col[20] = kYellow-10;
2137  col[24] = col[25] = col[26] = kBlue-8;
2138  col[29] = kOrange+9;
2139  col[79] = kOrange-2;
2140 
2141  TGeoVolume *vol;
2142  TIter next(fVolumes);
2143  while ((vol=(TGeoVolume*)next())) {
2144  TGeoMedium *med = vol->GetMedium();
2145  if (!med) continue;
2146  TGeoMaterial *mat = med->GetMaterial();
2147  Int_t matZ = (Int_t)mat->GetZ();
2148  vol->SetLineColor(col[matZ]);
2149  if (mat->GetDensity()<0.1) vol->SetTransparency(60);
2150  }
2151 }
2152 
2153 ////////////////////////////////////////////////////////////////////////////////
2154 /// Compute safe distance from the current point. This represent the distance
2155 /// from POINT to the closest boundary.
2156 
2158 {
2159  return GetCurrentNavigator()->Safety(inside);
2160 }
2161 
2162 ////////////////////////////////////////////////////////////////////////////////
2163 /// Set volume attributes in G3 style.
2164 
2165 void TGeoManager::SetVolumeAttribute(const char *name, const char *att, Int_t val)
2166 {
2167  TGeoVolume *volume;
2168  Bool_t all = kFALSE;
2169  if (strstr(name,"*")) all=kTRUE;
2170  Int_t ivo=0;
2171  TIter next(fVolumes);
2172  TString chatt = att;
2173  chatt.ToLower();
2174  while ((volume=(TGeoVolume*)next())) {
2175  if (strcmp(volume->GetName(), name) && !all) continue;
2176  ivo++;
2177  if (chatt.Contains("colo")) volume->SetLineColor(val);
2178  if (chatt.Contains("lsty")) volume->SetLineStyle(val);
2179  if (chatt.Contains("lwid")) volume->SetLineWidth(val);
2180  if (chatt.Contains("fill")) volume->SetFillColor(val);
2181  if (chatt.Contains("seen")) volume->SetVisibility(val);
2182  }
2183  TIter next1(fGVolumes);
2184  while ((volume=(TGeoVolume*)next1())) {
2185  if (strcmp(volume->GetName(), name) && !all) continue;
2186  ivo++;
2187  if (chatt.Contains("colo")) volume->SetLineColor(val);
2188  if (chatt.Contains("lsty")) volume->SetLineStyle(val);
2189  if (chatt.Contains("lwid")) volume->SetLineWidth(val);
2190  if (chatt.Contains("fill")) volume->SetFillColor(val);
2191  if (chatt.Contains("seen")) volume->SetVisibility(val);
2192  }
2193  if (!ivo) {
2194  Warning("SetVolumeAttribute","volume: %s does not exist",name);
2195  }
2196 }
2197 ////////////////////////////////////////////////////////////////////////////////
2198 /// Set factors that will "bomb" all translations in cartesian and cylindrical coordinates.
2199 
2201 {
2202  if (fPainter) fPainter->SetBombFactors(bombx, bomby, bombz, bombr);
2203 }
2204 
2205 ////////////////////////////////////////////////////////////////////////////////
2206 /// Set a user-defined shape as clipping for ray tracing.
2207 
2209 {
2210  TVirtualGeoPainter *painter = GetGeomPainter();
2211  if (shape) {
2213  fClippingShape = shape;
2214  }
2215  painter->SetClippingShape(shape);
2216 }
2217 
2218 ////////////////////////////////////////////////////////////////////////////////
2219 /// set the maximum number of visible nodes.
2220 
2222  fMaxVisNodes = maxnodes;
2223  if (maxnodes>0 && fgVerboseLevel>0)
2224  Info("SetMaxVisNodes","Automatic visible depth for %d visible nodes", maxnodes);
2225  if (!fPainter) return;
2227  Int_t level = fPainter->GetVisLevel();
2228  if (level != fVisLevel) fVisLevel = level;
2229 }
2230 
2231 ////////////////////////////////////////////////////////////////////////////////
2232 /// make top volume visible on screen
2233 
2235  GetGeomPainter();
2236  fPainter->SetTopVisible(vis);
2237 }
2238 
2239 ////////////////////////////////////////////////////////////////////////////////
2240 /// Assign a given node to be checked for ovelaps. Any other overlaps will be ignored.
2241 
2243  GetGeomPainter()->SetCheckedNode(node);
2244 }
2245 ////////////////////////////////////////////////////////////////////////////////
2246 /// Set the number of points to be generated on the shape outline when checking
2247 /// for overlaps.
2248 
2250 {
2251  GetGeomPainter()->SetNmeshPoints(npoints);
2252 }
2253 
2254 ////////////////////////////////////////////////////////////////////////////////
2255 /// set drawing mode :
2256 /// option=0 (default) all nodes drawn down to vislevel
2257 /// option=1 leaves and nodes at vislevel drawn
2258 /// option=2 path is drawn
2259 /// option=4 visibility changed
2260 
2262  if ((option>=0) && (option<3)) fVisOption=option;
2263  if (fPainter) fPainter->SetVisOption(option);
2264 }
2265 
2266 ////////////////////////////////////////////////////////////////////////////////
2267 /// Set visualization option (leaves only OR all volumes)
2268 
2270 {
2271  if (flag) SetVisOption(1);
2272  else SetVisOption(0);
2273 }
2274 
2275 ////////////////////////////////////////////////////////////////////////////////
2276 /// Set density threshold. Volumes with densities lower than this become
2277 /// transparent.
2278 
2280 {
2281  fVisDensity = density;
2282  if (fPainter) fPainter->ModifiedPad();
2283 }
2284 
2285 ////////////////////////////////////////////////////////////////////////////////
2286 /// set default level down to which visualization is performed
2287 
2289  if (level>0) {
2290  fVisLevel = level;
2291  fMaxVisNodes = 0;
2292  if (fgVerboseLevel>0)
2293  Info("SetVisLevel","Automatic visible depth disabled");
2295  } else {
2296  SetMaxVisNodes();
2297  }
2298 }
2299 
2300 ////////////////////////////////////////////////////////////////////////////////
2301 /// Sort overlaps by decreasing overlap distance. Extrusions comes first.
2302 
2304 {
2305  fOverlaps->Sort();
2306 }
2307 
2308 ////////////////////////////////////////////////////////////////////////////////
2309 /// Optimize voxelization type for all volumes. Save best choice in a macro.
2310 
2312 {
2313  if (!fTopNode) {
2314  Error("OptimizeVoxels","Geometry must be closed first");
2315  return;
2316  }
2317  std::ofstream out;
2318  TString fname = filename;
2319  if (fname.IsNull()) fname = "tgeovox.C";
2320  out.open(fname, std::ios::out);
2321  if (!out.good()) {
2322  Error("OptimizeVoxels", "cannot open file");
2323  return;
2324  }
2325  // write header
2326  TDatime t;
2327  TString sname(fname);
2328  sname.ReplaceAll(".C", "");
2329  out << sname.Data()<<"()"<<std::endl;
2330  out << "{" << std::endl;
2331  out << "//=== Macro generated by ROOT version "<< gROOT->GetVersion()<<" : "<<t.AsString()<<std::endl;
2332  out << "//=== Voxel optimization for " << GetTitle() << " geometry"<<std::endl;
2333  out << "//===== <run this macro JUST BEFORE closing the geometry>"<<std::endl;
2334  out << " TGeoVolume *vol = 0;"<<std::endl;
2335  out << " // parse all voxelized volumes"<<std::endl;
2336  TGeoVolume *vol = 0;
2337  Bool_t cyltype;
2338  TIter next(fVolumes);
2339  while ((vol=(TGeoVolume*)next())) {
2340  if (!vol->GetVoxels()) continue;
2341  out<<" vol = gGeoManager->GetVolume(\""<<vol->GetName()<<"\");"<<std::endl;
2342  cyltype = vol->OptimizeVoxels();
2343  if (cyltype) {
2344  out<<" vol->SetCylVoxels();"<<std::endl;
2345  } else {
2346  out<<" vol->SetCylVoxels(kFALSE);"<<std::endl;
2347  }
2348  }
2349  out << "}" << std::endl;
2350  out.close();
2351 }
2352 ////////////////////////////////////////////////////////////////////////////////
2353 /// Parse a string boolean expression and do a syntax check. Find top
2354 /// level boolean operator and returns its type. Fill the two
2355 /// substrings to which this operator applies. The returned integer is :
2356 /// -1 : parse error
2357 /// 0 : no boolean operator
2358 /// 1 : union - represented as '+' in expression
2359 /// 2 : difference (subtraction) - represented as '-' in expression
2360 /// 3 : intersection - represented as '*' in expression.
2361 /// Paranthesys should be used to avoid ambiguites. For instance :
2362 /// A+B-C will be interpreted as (A+B)-C which is not the same as A+(B-C)
2363 /// eliminate not needed paranthesys
2364 
2365 Int_t TGeoManager::Parse(const char *expr, TString &expr1, TString &expr2, TString &expr3)
2366 {
2367  TString startstr(expr);
2368  Int_t len = startstr.Length();
2369  Int_t i;
2370  TString e0 = "";
2371  expr3 = "";
2372  // eliminate blanks
2373  for (i=0; i< len; i++) {
2374  if (startstr(i)==' ') continue;
2375  e0 += startstr(i, 1);
2376  }
2377  Int_t level = 0;
2378  Int_t levmin = 999;
2379  Int_t boolop = 0;
2380  Int_t indop = 0;
2381  Int_t iloop = 1;
2382  Int_t lastop = 0;
2383  Int_t lastdp = 0;
2384  Int_t lastpp = 0;
2385  Bool_t foundmat = kFALSE;
2386  // check/eliminate paranthesys
2387  while (iloop==1) {
2388  iloop = 0;
2389  lastop = 0;
2390  lastdp = 0;
2391  lastpp = 0;
2392  len = e0.Length();
2393  for (i=0; i<len; i++) {
2394  if (e0(i)=='(') {
2395  if (!level) iloop++;
2396  level++;
2397  continue;
2398  }
2399  if (e0(i)==')') {
2400  level--;
2401  if (level==0) lastpp=i;
2402  continue;
2403  }
2404  if ((e0(i)=='+') || (e0(i)=='-') || (e0(i)=='*')) {
2405  lastop = i;
2406  if (level<levmin) {
2407  levmin = level;
2408  indop = i;
2409  }
2410  continue;
2411  }
2412  if ((e0(i)==':') && (level==0)) {
2413  lastdp = i;
2414  continue;
2415  }
2416  }
2417  if (level!=0) {
2418  if (gGeoManager) gGeoManager->Error("Parse","paranthesys does not match");
2419  return -1;
2420  }
2421  if (iloop==1 && (e0(0)=='(') && (e0(len-1)==')')) {
2422  // eliminate extra paranthesys
2423  e0=e0(1, len-2);
2424  continue;
2425  }
2426  if (foundmat) break;
2427  if (((lastop==0) && (lastdp>0)) || ((lastpp>0) && (lastdp>lastpp) && (indop<lastpp))) {
2428  expr3 = e0(lastdp+1, len-lastdp);
2429  e0=e0(0, lastdp);
2430  foundmat = kTRUE;
2431  iloop = 1;
2432  continue;
2433  } else break;
2434  }
2435  // loop expression and search paranthesys/operators
2436  levmin = 999;
2437  for (i=0; i<len; i++) {
2438  if (e0(i)=='(') {
2439  level++;
2440  continue;
2441  }
2442  if (e0(i)==')') {
2443  level--;
2444  continue;
2445  }
2446  // Take LAST operator at lowest level (revision 28/07/08)
2447  if (level<=levmin) {
2448  if (e0(i)=='+') {
2449  boolop = 1; // union
2450  levmin = level;
2451  indop = i;
2452  }
2453  if (e0(i)=='-') {
2454  boolop = 2; // difference
2455  levmin = level;
2456  indop = i;
2457  }
2458  if (e0(i)=='*') {
2459  boolop = 3; // intersection
2460  levmin = level;
2461  indop = i;
2462  }
2463  }
2464  }
2465  if (indop==0) {
2466  expr1=e0;
2467  return indop;
2468  }
2469  expr1 = e0(0, indop);
2470  expr2 = e0(indop+1, len-indop);
2471  return boolop;
2472 }
2473 
2474 
2475 ////////////////////////////////////////////////////////////////////////////////
2476 /// Save current attributes in a macro
2477 
2479 {
2480  if (!fTopNode) {
2481  Error("SaveAttributes","geometry must be closed first\n");
2482  return;
2483  }
2484  std::ofstream out;
2485  TString fname(filename);
2486  if (fname.IsNull()) fname = "tgeoatt.C";
2487  out.open(fname, std::ios::out);
2488  if (!out.good()) {
2489  Error("SaveAttributes", "cannot open file");
2490  return;
2491  }
2492  // write header
2493  TDatime t;
2494  TString sname(fname);
2495  sname.ReplaceAll(".C", "");
2496  out << sname.Data()<<"()"<<std::endl;
2497  out << "{" << std::endl;
2498  out << "//=== Macro generated by ROOT version "<< gROOT->GetVersion()<<" : "<<t.AsString()<<std::endl;
2499  out << "//=== Attributes for " << GetTitle() << " geometry"<<std::endl;
2500  out << "//===== <run this macro AFTER loading the geometry in memory>"<<std::endl;
2501  // save current top volume
2502  out << " TGeoVolume *top = gGeoManager->GetVolume(\""<<fTopVolume->GetName()<<"\");"<<std::endl;
2503  out << " TGeoVolume *vol = 0;"<<std::endl;
2504  out << " TGeoNode *node = 0;"<<std::endl;
2505  out << " // clear all volume attributes and get painter"<<std::endl;
2506  out << " gGeoManager->ClearAttributes();"<<std::endl;
2507  out << " gGeoManager->GetGeomPainter();"<<std::endl;
2508  out << " // set visualization modes and bomb factors"<<std::endl;
2509  out << " gGeoManager->SetVisOption("<<GetVisOption()<<");"<<std::endl;
2510  out << " gGeoManager->SetVisLevel("<<GetVisLevel()<<");"<<std::endl;
2511  out << " gGeoManager->SetExplodedView("<<GetBombMode()<<");"<<std::endl;
2512  Double_t bombx, bomby, bombz, bombr;
2513  GetBombFactors(bombx, bomby, bombz, bombr);
2514  out << " gGeoManager->SetBombFactors("<<bombx<<","<<bomby<<","<<bombz<<","<<bombr<<");"<<std::endl;
2515  out << " // iterate volumes coontainer and set new attributes"<<std::endl;
2516 // out << " TIter next(gGeoManager->GetListOfVolumes());"<<std::endl;
2517  TGeoVolume *vol = 0;
2518  fTopNode->SaveAttributes(out);
2519 
2520  TIter next(fVolumes);
2521  while ((vol=(TGeoVolume*)next())) {
2522  vol->SetVisStreamed(kFALSE);
2523  }
2524  out << " // draw top volume with new settings"<<std::endl;
2525  out << " top->Draw();"<<std::endl;
2526  out << " gPad->x3d();"<<std::endl;
2527  out << "}" << std::endl;
2528  out.close();
2529 }
2530 ////////////////////////////////////////////////////////////////////////////////
2531 /// Returns the deepest node containing fPoint, which must be set a priori.
2532 
2533 TGeoNode *TGeoManager::SearchNode(Bool_t downwards, const TGeoNode *skipnode)
2534 {
2535  return GetCurrentNavigator()->SearchNode(downwards, skipnode);
2536 }
2537 
2538 ////////////////////////////////////////////////////////////////////////////////
2539 /// Cross next boundary and locate within current node
2540 /// The current point must be on the boundary of fCurrentNode.
2541 
2543 {
2544  return GetCurrentNavigator()->CrossBoundaryAndLocate(downwards, skipnode);
2545 }
2546 
2547 ////////////////////////////////////////////////////////////////////////////////
2548 /// Compute distance to next boundary within STEPMAX. If no boundary is found,
2549 /// propagate current point along current direction with fStep=STEPMAX. Otherwise
2550 /// propagate with fStep=SNEXT (distance to boundary) and locate/return the next
2551 /// node.
2552 
2554 {
2555  return GetCurrentNavigator()->FindNextBoundaryAndStep(stepmax, compsafe);
2556 }
2557 
2558 ////////////////////////////////////////////////////////////////////////////////
2559 /// Find distance to next boundary and store it in fStep. Returns node to which this
2560 /// boundary belongs. If PATH is specified, compute only distance to the node to which
2561 /// PATH points. If STEPMAX is specified, compute distance only in case fSafety is smaller
2562 /// than this value. STEPMAX represent the step to be made imposed by other reasons than
2563 /// geometry (usually physics processes). Therefore in this case this method provides the
2564 /// answer to the question : "Is STEPMAX a safe step ?" returning a NULL node and filling
2565 /// fStep with a big number.
2566 /// In case frombdr=kTRUE, the isotropic safety is set to zero.
2567 /// Note : safety distance for the current point is computed ONLY in case STEPMAX is
2568 /// specified, otherwise users have to call explicitly TGeoManager::Safety() if
2569 /// they want this computed for the current point.
2570 
2571 TGeoNode *TGeoManager::FindNextBoundary(Double_t stepmax, const char *path, Bool_t frombdr)
2572 {
2573  // convert current point and direction to local reference
2574  return GetCurrentNavigator()->FindNextBoundary(stepmax,path, frombdr);
2575 }
2576 
2577 ////////////////////////////////////////////////////////////////////////////////
2578 /// Computes as fStep the distance to next daughter of the current volume.
2579 /// The point and direction must be converted in the coordinate system of the current volume.
2580 /// The proposed step limit is fStep.
2581 
2583 {
2584  return GetCurrentNavigator()->FindNextDaughterBoundary(point, dir, idaughter, compmatrix);
2585 }
2586 
2587 ////////////////////////////////////////////////////////////////////////////////
2588 /// Reset current state flags.
2589 
2591 {
2593 }
2594 
2595 ////////////////////////////////////////////////////////////////////////////////
2596 /// Returns deepest node containing current point.
2597 
2599 {
2600  return GetCurrentNavigator()->FindNode(safe_start);
2601 }
2602 
2603 ////////////////////////////////////////////////////////////////////////////////
2604 /// Returns deepest node containing current point.
2605 
2607 {
2608  return GetCurrentNavigator()->FindNode(x, y, z);
2609 }
2610 
2611 ////////////////////////////////////////////////////////////////////////////////
2612 /// Computes fast normal to next crossed boundary, assuming that the current point
2613 /// is close enough to the boundary. Works only after calling FindNextBoundary.
2614 
2616 {
2617  return GetCurrentNavigator()->FindNormalFast();
2618 }
2619 
2620 ////////////////////////////////////////////////////////////////////////////////
2621 /// Computes normal vector to the next surface that will be or was already
2622 /// crossed when propagating on a straight line from a given point/direction.
2623 /// Returns the normal vector cosines in the MASTER coordinate system. The dot
2624 /// product of the normal and the current direction is positive defined.
2625 
2627 {
2628  return GetCurrentNavigator()->FindNormal(forward);
2629 }
2630 
2631 ////////////////////////////////////////////////////////////////////////////////
2632 /// Checks if point (x,y,z) is still in the current node.
2633 
2635 {
2636  return GetCurrentNavigator()->IsSameLocation(x,y,z,change);
2637 }
2638 
2639 ////////////////////////////////////////////////////////////////////////////////
2640 /// Check if a new point with given coordinates is the same as the last located one.
2641 
2643 {
2644  return GetCurrentNavigator()->IsSamePoint(x,y,z);
2645 }
2646 
2647 ////////////////////////////////////////////////////////////////////////////////
2648 /// True if current node is in phi range
2649 
2651 {
2652  if (!fPhiCut) return kTRUE;
2653  const Double_t *origin;
2655  origin = ((TGeoBBox*)GetCurrentNavigator()->GetCurrentVolume()->GetShape())->GetOrigin();
2656  Double_t point[3];
2657  LocalToMaster(origin, &point[0]);
2658  Double_t phi = TMath::ATan2(point[1], point[0])*TMath::RadToDeg();
2659  if (phi<0) phi+=360.;
2660  if ((phi>=fPhimin) && (phi<=fPhimax)) return kFALSE;
2661  return kTRUE;
2662 }
2663 
2664 ////////////////////////////////////////////////////////////////////////////////
2665 /// Initialize current point and current direction vector (normalized)
2666 /// in MARS. Return corresponding node.
2667 
2669 {
2670  return GetCurrentNavigator()->InitTrack(point, dir);
2671 }
2672 
2673 ////////////////////////////////////////////////////////////////////////////////
2674 /// Initialize current point and current direction vector (normalized)
2675 /// in MARS. Return corresponding node.
2676 
2678 {
2679  return GetCurrentNavigator()->InitTrack(x,y,z,nx,ny,nz);
2680 }
2681 
2682 ////////////////////////////////////////////////////////////////////////////////
2683 /// Inspects path and all flags for the current state.
2684 
2686 {
2688 }
2689 
2690 ////////////////////////////////////////////////////////////////////////////////
2691 /// Get path to the current node in the form /node0/node1/...
2692 
2693 const char *TGeoManager::GetPath() const
2694 {
2695  return GetCurrentNavigator()->GetPath();
2696 }
2697 
2698 ////////////////////////////////////////////////////////////////////////////////
2699 /// Get total size of geometry in bytes.
2700 
2702 {
2703  Int_t count = 0;
2704  TIter next(fVolumes);
2705  TGeoVolume *vol;
2706  while ((vol=(TGeoVolume*)next())) count += vol->GetByteCount();
2707  TIter next1(fMatrices);
2708  TGeoMatrix *matrix;
2709  while ((matrix=(TGeoMatrix*)next1())) count += matrix->GetByteCount();
2710  TIter next2(fMaterials);
2711  TGeoMaterial *mat;
2712  while ((mat=(TGeoMaterial*)next2())) count += mat->GetByteCount();
2713  TIter next3(fMedia);
2714  TGeoMedium *med;
2715  while ((med=(TGeoMedium*)next3())) count += med->GetByteCount();
2716  if (fgVerboseLevel>0) Info("GetByteCount","Total size of logical tree : %i bytes", count);
2717  return count;
2718 }
2719 ////////////////////////////////////////////////////////////////////////////////
2720 /// Make a default painter if none present. Returns pointer to it.
2721 
2723 {
2724  if (!fPainter) {
2725  TPluginHandler *h;
2726  if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualGeoPainter"))) {
2727  if (h->LoadPlugin() == -1)
2728  return 0;
2729  fPainter = (TVirtualGeoPainter*)h->ExecPlugin(1,this);
2730  if (!fPainter) {
2731  Error("GetGeomPainter", "could not create painter");
2732  return 0;
2733  }
2734  }
2735  }
2736  return fPainter;
2737 }
2738 ////////////////////////////////////////////////////////////////////////////////
2739 /// Search for a named volume. All trailing blanks stripped.
2740 
2742 {
2743  TString sname = name;
2744  sname = sname.Strip();
2745  TGeoVolume *vol = (TGeoVolume*)fVolumes->FindObject(sname.Data());
2746  return vol;
2747 }
2748 
2749 ////////////////////////////////////////////////////////////////////////////////
2750 /// Fast search for a named volume. All trailing blanks stripped.
2751 
2753 {
2754  if (!fHashVolumes) {
2755  Int_t nvol = fVolumes->GetEntriesFast();
2756  Int_t ngvol = fGVolumes->GetEntriesFast();
2757  fHashVolumes = new THashList(nvol+1);
2758  fHashGVolumes = new THashList(ngvol+1);
2759  Int_t i;
2760  for (i=0; i<ngvol; i++) fHashGVolumes->AddLast(fGVolumes->At(i));
2761  for (i=0; i<nvol; i++) fHashVolumes->AddLast(fVolumes->At(i));
2762  }
2763  TString sname = name;
2764  sname = sname.Strip();
2765  THashList *list = fHashVolumes;
2766  if (multi) list = fHashGVolumes;
2767  TGeoVolume *vol = (TGeoVolume*)list->FindObject(sname.Data());
2768  return vol;
2769 }
2770 
2771 ////////////////////////////////////////////////////////////////////////////////
2772 /// Retreive unique id for a volume name. Return -1 if name not found.
2773 
2774 Int_t TGeoManager::GetUID(const char *volname) const
2775 {
2776  TGeoManager *geom = (TGeoManager*)this;
2777  TGeoVolume *vol = geom->FindVolumeFast(volname, kFALSE);
2778  if (!vol) vol = geom->FindVolumeFast(volname, kTRUE);
2779  if (!vol) return -1;
2780  return vol->GetNumber();
2781 }
2782 
2783 ////////////////////////////////////////////////////////////////////////////////
2784 /// Find if a given material duplicates an existing one.
2785 
2787 {
2788  Int_t index = fMaterials->IndexOf(mat);
2789  if (index <= 0) return 0;
2790  TGeoMaterial *other;
2791  for (Int_t i=0; i<index; i++) {
2792  other = (TGeoMaterial*)fMaterials->At(i);
2793  if (other == mat) continue;
2794  if (other->IsEq(mat)) return other;
2795  }
2796  return 0;
2797 }
2798 
2799 ////////////////////////////////////////////////////////////////////////////////
2800 /// Search for a named material. All trailing blanks stripped.
2801 
2802 TGeoMaterial *TGeoManager::GetMaterial(const char *matname) const
2803 {
2804  TString sname = matname;
2805  sname = sname.Strip();
2806  TGeoMaterial *mat = (TGeoMaterial*)fMaterials->FindObject(sname.Data());
2807  return mat;
2808 }
2809 
2810 ////////////////////////////////////////////////////////////////////////////////
2811 /// Search for a named tracking medium. All trailing blanks stripped.
2812 
2813 TGeoMedium *TGeoManager::GetMedium(const char *medium) const
2814 {
2815  TString sname = medium;
2816  sname = sname.Strip();
2817  TGeoMedium *med = (TGeoMedium*)fMedia->FindObject(sname.Data());
2818  return med;
2819 }
2820 
2821 ////////////////////////////////////////////////////////////////////////////////
2822 /// Search for a tracking medium with a given ID.
2823 
2825 {
2826  TIter next(fMedia);
2827  TGeoMedium *med;
2828  while ((med=(TGeoMedium*)next())) {
2829  if (med->GetId()==numed) return med;
2830  }
2831  return 0;
2832 }
2833 
2834 ////////////////////////////////////////////////////////////////////////////////
2835 /// Return material at position id.
2836 
2838 {
2839  if (id<0 || id >= fMaterials->GetSize()) return 0;
2840  TGeoMaterial *mat = (TGeoMaterial*)fMaterials->At(id);
2841  return mat;
2842 }
2843 ////////////////////////////////////////////////////////////////////////////////
2844 /// Return index of named material.
2845 
2846 Int_t TGeoManager::GetMaterialIndex(const char *matname) const
2847 {
2849  TGeoMaterial *mat;
2850  Int_t id = 0;
2851  TString sname = matname;
2852  sname = sname.Strip();
2853  while ((mat = (TGeoMaterial*)next())) {
2854  if (!strcmp(mat->GetName(),sname.Data()))
2855  return id;
2856  id++;
2857  }
2858  return -1; // fail
2859 }
2860 ////////////////////////////////////////////////////////////////////////////////
2861 /// Randomly shoot nrays and plot intersections with surfaces for current
2862 /// top node.
2863 
2864 void TGeoManager::RandomRays(Int_t nrays, Double_t startx, Double_t starty, Double_t startz, const char *target_vol, Bool_t check_norm)
2865 {
2866  GetGeomPainter()->RandomRays(nrays, startx, starty, startz, target_vol, check_norm);
2867 }
2868 
2869 ////////////////////////////////////////////////////////////////////////////////
2870 /// Remove material at given index.
2871 
2873 {
2874  TObject *obj = fMaterials->At(index);
2875  if (obj) fMaterials->Remove(obj);
2876 }
2877 
2878 ////////////////////////////////////////////////////////////////////////////////
2879 /// Sets all pointers TGeoVolume::fField to NULL. User data becomes decoupled
2880 /// from geometry. Deletion has to be managed by users.
2881 
2883 {
2884  TIter next(fVolumes);
2885  TGeoVolume *vol;
2886  while ((vol=(TGeoVolume*)next())) vol->SetField(0);
2887 }
2888 
2889 ////////////////////////////////////////////////////////////////////////////////
2890 /// Restore the master volume of the geometry.
2891 
2893 {
2894  if (fTopVolume == fMasterVolume) return;
2896 }
2897 ////////////////////////////////////////////////////////////////////////////////
2898 /// Voxelize all non-divided volumes.
2899 
2901 {
2902  TGeoVolume *vol;
2903 // TGeoVoxelFinder *vox = 0;
2904  if (!fStreamVoxels && fgVerboseLevel>0) Info("Voxelize","Voxelizing...");
2905 // Int_t nentries = fVolumes->GetSize();
2906  TIter next(fVolumes);
2907  while ((vol = (TGeoVolume*)next())) {
2908  if (!fIsGeomReading) vol->SortNodes();
2909  if (!fStreamVoxels) {
2910  vol->Voxelize(option);
2911  }
2912  if (!fIsGeomReading) vol->FindOverlaps();
2913  }
2914 }
2915 ////////////////////////////////////////////////////////////////////////////////
2916 /// Send "Modified" signal to painter.
2917 
2919 {
2920  if (!fPainter) return;
2921  fPainter->ModifiedPad();
2922 }
2923 ////////////////////////////////////////////////////////////////////////////////
2924 /// Make an TGeoArb8 volume.
2925 
2927  Double_t dz, Double_t *vertices)
2928 {
2929  return TGeoBuilder::Instance(this)->MakeArb8(name, medium, dz, vertices);
2930 }
2931 
2932 ////////////////////////////////////////////////////////////////////////////////
2933 /// Make in one step a volume pointing to a box shape with given medium.
2934 
2936  Double_t dx, Double_t dy, Double_t dz)
2937 {
2938  return TGeoBuilder::Instance(this)->MakeBox(name, medium, dx, dy, dz);
2939 }
2940 
2941 ////////////////////////////////////////////////////////////////////////////////
2942 /// Make in one step a volume pointing to a paralelipiped shape with given medium.
2943 
2945  Double_t dx, Double_t dy, Double_t dz,
2947 {
2948  return TGeoBuilder::Instance(this)->MakePara(name, medium, dx, dy, dz, alpha, theta, phi);
2949 }
2950 
2951 ////////////////////////////////////////////////////////////////////////////////
2952 /// Make in one step a volume pointing to a sphere shape with given medium
2953 
2955  Double_t rmin, Double_t rmax, Double_t themin, Double_t themax,
2956  Double_t phimin, Double_t phimax)
2957 {
2958  return TGeoBuilder::Instance(this)->MakeSphere(name, medium, rmin, rmax, themin, themax, phimin, phimax);
2959 }
2960 
2961 ////////////////////////////////////////////////////////////////////////////////
2962 /// Make in one step a volume pointing to a torus shape with given medium.
2963 
2965  Double_t rmin, Double_t rmax, Double_t phi1, Double_t dphi)
2966 {
2967  return TGeoBuilder::Instance(this)->MakeTorus(name, medium, r, rmin, rmax, phi1, dphi);
2968 }
2969 
2970 ////////////////////////////////////////////////////////////////////////////////
2971 /// Make in one step a volume pointing to a tube shape with given medium.
2972 
2974  Double_t rmin, Double_t rmax, Double_t dz)
2975 {
2976  return TGeoBuilder::Instance(this)->MakeTube(name, medium, rmin, rmax, dz);
2977 }
2978 
2979 ////////////////////////////////////////////////////////////////////////////////
2980 /// Make in one step a volume pointing to a tube segment shape with given medium.
2981 /// The segment will be from phiStart to phiEnd, the angles are expressed in degree
2982 
2984  Double_t rmin, Double_t rmax, Double_t dz,
2985  Double_t phiStart, Double_t phiEnd)
2986 {
2987  return TGeoBuilder::Instance(this)->MakeTubs(name, medium, rmin, rmax, dz, phiStart, phiEnd);
2988 }
2989 
2990 ////////////////////////////////////////////////////////////////////////////////
2991 /// Make in one step a volume pointing to a tube shape with given medium
2992 
2994  Double_t a, Double_t b, Double_t dz)
2995 {
2996  return TGeoBuilder::Instance(this)->MakeEltu(name, medium, a, b, dz);
2997 }
2998 
2999 ////////////////////////////////////////////////////////////////////////////////
3000 /// Make in one step a volume pointing to a tube shape with given medium
3001 
3003  Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
3004 {
3005  return TGeoBuilder::Instance(this)->MakeHype(name, medium, rin, stin, rout, stout, dz);
3006 }
3007 
3008 ////////////////////////////////////////////////////////////////////////////////
3009 /// Make in one step a volume pointing to a tube shape with given medium
3010 
3012  Double_t rlo, Double_t rhi, Double_t dz)
3013 {
3014  return TGeoBuilder::Instance(this)->MakeParaboloid(name, medium, rlo, rhi, dz);
3015 }
3016 
3017 ////////////////////////////////////////////////////////////////////////////////
3018 /// Make in one step a volume pointing to a tube segment shape with given medium
3019 
3021  Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2,
3022  Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
3023 {
3024  return TGeoBuilder::Instance(this)->MakeCtub(name, medium, rmin, rmax, dz, phi1, phi2, lx, ly, lz, tx, ty, tz);
3025 }
3026 
3027 ////////////////////////////////////////////////////////////////////////////////
3028 /// Make in one step a volume pointing to a cone shape with given medium.
3029 
3031  Double_t dz, Double_t rmin1, Double_t rmax1,
3032  Double_t rmin2, Double_t rmax2)
3033 {
3034  return TGeoBuilder::Instance(this)->MakeCone(name, medium, dz, rmin1, rmax1, rmin2, rmax2);
3035 }
3036 
3037 ////////////////////////////////////////////////////////////////////////////////
3038 /// Make in one step a volume pointing to a cone segment shape with given medium
3039 
3041  Double_t dz, Double_t rmin1, Double_t rmax1,
3042  Double_t rmin2, Double_t rmax2,
3043  Double_t phi1, Double_t phi2)
3044 {
3045  return TGeoBuilder::Instance(this)->MakeCons(name, medium, dz, rmin1, rmax1, rmin2, rmax2, phi1, phi2);
3046 }
3047 
3048 ////////////////////////////////////////////////////////////////////////////////
3049 /// Make in one step a volume pointing to a polycone shape with given medium.
3050 
3052  Double_t phi, Double_t dphi, Int_t nz)
3053 {
3054  return TGeoBuilder::Instance(this)->MakePcon(name, medium, phi, dphi, nz);
3055 }
3056 
3057 ////////////////////////////////////////////////////////////////////////////////
3058 /// Make in one step a volume pointing to a polygone shape with given medium.
3059 
3061  Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
3062 {
3063  return TGeoBuilder::Instance(this)->MakePgon(name, medium, phi, dphi, nedges, nz);
3064 }
3065 
3066 ////////////////////////////////////////////////////////////////////////////////
3067 /// Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
3068 
3070  Double_t dx1, Double_t dx2, Double_t dy, Double_t dz)
3071 {
3072  return TGeoBuilder::Instance(this)->MakeTrd1(name, medium, dx1, dx2, dy, dz);
3073 }
3074 
3075 ////////////////////////////////////////////////////////////////////////////////
3076 /// Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
3077 
3079  Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2,
3080  Double_t dz)
3081 {
3082  return TGeoBuilder::Instance(this)->MakeTrd2(name, medium, dx1, dx2, dy1, dy2, dz);
3083 }
3084 
3085 ////////////////////////////////////////////////////////////////////////////////
3086 /// Make in one step a volume pointing to a trapezoid shape with given medium.
3087 
3090  Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
3091  Double_t tl2, Double_t alpha2)
3092 {
3093  return TGeoBuilder::Instance(this)->MakeTrap(name, medium, dz, theta, phi, h1, bl1, tl1, alpha1, h2, bl2, tl2, alpha2);
3094 }
3095 
3096 ////////////////////////////////////////////////////////////////////////////////
3097 /// Make in one step a volume pointing to a twisted trapezoid shape with given medium.
3098 
3101  Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2,
3102  Double_t tl2, Double_t alpha2)
3103 {
3104  return TGeoBuilder::Instance(this)->MakeGtra(name, medium, dz, theta, phi, twist, h1, bl1, tl1, alpha1, h2, bl2, tl2, alpha2);
3105 }
3106 
3107 ////////////////////////////////////////////////////////////////////////////////
3108 /// Make a TGeoXtru-shaped volume with nz planes
3109 
3111 {
3112  return TGeoBuilder::Instance(this)->MakeXtru(name, medium, nz);
3113 }
3114 
3115 ////////////////////////////////////////////////////////////////////////////////
3116 /// Creates an aligneable object with unique name corresponding to a path
3117 /// and adds it to the list of alignables. An optional unique ID can be
3118 /// provided, in which case PN entries can be searched fast by uid.
3119 
3120 TGeoPNEntry *TGeoManager::SetAlignableEntry(const char *unique_name, const char *path,
3121  Int_t uid)
3122 {
3123  if (!CheckPath(path)) return NULL;
3124  if (!fHashPNE) fHashPNE = new THashList(256,3);
3125  if (!fArrayPNE) fArrayPNE = new TObjArray(256);
3126  TGeoPNEntry *entry = GetAlignableEntry(unique_name);
3127  if (entry) {
3128  Error("SetAlignableEntry", "An alignable object with name %s already existing. NOT ADDED !", unique_name);
3129  return 0;
3130  }
3131  entry = new TGeoPNEntry(unique_name, path);
3132  Int_t ientry = fHashPNE->GetSize();
3133  fHashPNE->Add(entry);
3134  fArrayPNE->AddAtAndExpand(entry, ientry);
3135  if (uid>=0) {
3136  Bool_t added = InsertPNEId(uid, ientry);
3137  if (!added) Error("SetAlignableEntry", "A PN entry: has already uid=%i", uid);
3138  }
3139  return entry;
3140 }
3141 
3142 ////////////////////////////////////////////////////////////////////////////////
3143 /// Retreives an existing alignable object.
3144 
3146 {
3147  if (!fHashPNE) return 0;
3148  return (TGeoPNEntry*)fHashPNE->FindObject(name);
3149 }
3150 
3151 ////////////////////////////////////////////////////////////////////////////////
3152 /// Retreives an existing alignable object at a given index.
3153 
3155 {
3156  if (!fArrayPNE && !InitArrayPNE()) return 0;
3157  return (TGeoPNEntry*)fArrayPNE->At(index);
3158 }
3159 
3160 ////////////////////////////////////////////////////////////////////////////////
3161 /// Retreives an existing alignable object having a preset UID.
3162 
3164 {
3165  if (!fNPNEId || (!fArrayPNE && !InitArrayPNE())) return NULL;
3166  Int_t index = TMath::BinarySearch(fNPNEId, fKeyPNEId, uid);
3167  if (index<0 || fKeyPNEId[index]!=uid) return NULL;
3168  return (TGeoPNEntry*)fArrayPNE->At(fValuePNEId[index]);
3169 }
3170 
3171 ////////////////////////////////////////////////////////////////////////////////
3172 /// Retreives number of PN entries with or without UID.
3173 
3175 {
3176  if (!fHashPNE) return 0;
3177  if (with_uid) return fNPNEId;
3178  return fHashPNE->GetSize();
3179 }
3180 
3181 ////////////////////////////////////////////////////////////////////////////////
3182 /// Insert a PN entry in the sorted array of indexes.
3183 
3185 {
3186  if (!fSizePNEId) {
3187  // Create the arrays.
3188  fSizePNEId = 128;
3189  fKeyPNEId = new Int_t[fSizePNEId];
3190  memset(fKeyPNEId, 0, fSizePNEId*sizeof(Int_t));
3191  fValuePNEId = new Int_t[fSizePNEId];
3192  memset(fValuePNEId, 0, fSizePNEId*sizeof(Int_t));
3193  fKeyPNEId[fNPNEId] = uid;
3194  fValuePNEId[fNPNEId++] = ientry;
3195  return kTRUE;
3196  }
3197  // Search id in the existing array and return false if it already exists.
3198  Int_t index = TMath::BinarySearch(fNPNEId, fKeyPNEId, uid);
3199  if (index>0 && fKeyPNEId[index]==uid) return kFALSE;
3200  // Resize the arrays and insert the value
3201  Bool_t resize = (fNPNEId==fSizePNEId)?kTRUE:kFALSE;
3202  if (resize) {
3203  // Double the size of the array
3204  fSizePNEId *= 2;
3205  // Create new arrays of keys and values
3206  Int_t *keys = new Int_t[fSizePNEId];
3207  memset(keys, 0, fSizePNEId*sizeof(Int_t));
3208  Int_t *values = new Int_t[fSizePNEId];
3209  memset(values, 0, fSizePNEId*sizeof(Int_t));
3210  // Copy all keys<uid in the new keys array (0 to index)
3211  memcpy(keys, fKeyPNEId, (index+1)*sizeof(Int_t));
3212  memcpy(values, fValuePNEId, (index+1)*sizeof(Int_t));
3213  // Insert current key at index+1
3214  keys[index+1] = uid;
3215  values[index+1] = ientry;
3216  // Copy all remaining keys from the old to new array
3217  memcpy(&keys[index+2], &fKeyPNEId[index+1], (fNPNEId-index-1)*sizeof(Int_t));
3218  memcpy(&values[index+2], &fValuePNEId[index+1], (fNPNEId-index-1)*sizeof(Int_t));
3219  delete [] fKeyPNEId;
3220  fKeyPNEId = keys;
3221  delete [] fValuePNEId;
3222  fValuePNEId = values;
3223  fNPNEId++;
3224  return kTRUE;
3225  }
3226  // Insert the value in the existing arrays
3227  Int_t i;
3228  for (i=fNPNEId-1; i>index; i--) {
3229  fKeyPNEId[i+1] = fKeyPNEId[i];
3230  fValuePNEId[i+1] = fValuePNEId[i];
3231  }
3232  fKeyPNEId[index+1] = uid;
3233  fValuePNEId[index+1] = ientry;
3234  fNPNEId++;
3235  return kTRUE;
3236 }
3237 
3238 ////////////////////////////////////////////////////////////////////////////////
3239 /// Make a physical node from the path pointed by an alignable object with a given name.
3240 
3242 {
3244  if (!entry) {
3245  Error("MakeAlignablePN","No alignable object named %s found !", name);
3246  return 0;
3247  }
3248  return MakeAlignablePN(entry);
3249 }
3250 
3251 ////////////////////////////////////////////////////////////////////////////////
3252 /// Make a physical node from the path pointed by a given alignable object.
3253 
3255 {
3256  if (!entry) {
3257  Error("MakeAlignablePN","No alignable object specified !");
3258  return 0;
3259  }
3260  const char *path = entry->GetTitle();
3261  if (!cd(path)) {
3262  Error("MakeAlignablePN", "Alignable object %s poins to invalid path: %s",
3263  entry->GetName(), path);
3264  return 0;
3265  }
3266  TGeoPhysicalNode *node = MakePhysicalNode(path);
3267  entry->SetPhysicalNode(node);
3268  return node;
3269 }
3270 
3271 ////////////////////////////////////////////////////////////////////////////////
3272 /// Makes a physical node corresponding to a path. If PATH is not specified,
3273 /// makes physical node matching current modeller state.
3274 
3276 {
3277  TGeoPhysicalNode *node;
3278  if (path) {
3279  if (!CheckPath(path)) {
3280  Error("MakePhysicalNode", "path: %s not valid", path);
3281  return NULL;
3282  }
3283  node = new TGeoPhysicalNode(path);
3284  } else {
3285  node = new TGeoPhysicalNode(GetPath());
3286  }
3287  fPhysicalNodes->Add(node);
3288  return node;
3289 }
3290 
3291 ////////////////////////////////////////////////////////////////////////////////
3292 /// Refresh physical nodes to reflect the actual geometry paths after alignment
3293 /// was applied. Optionally locks physical nodes (default).
3294 
3296 {
3297  TIter next(gGeoManager->GetListOfPhysicalNodes());
3298  TGeoPhysicalNode *pn;
3299  while ((pn=(TGeoPhysicalNode*)next())) pn->Refresh();
3301  if (lock) LockGeometry();
3302 }
3303 
3304 ////////////////////////////////////////////////////////////////////////////////
3305 /// Clear the current list of physical nodes, so that we can start over with a new list.
3306 /// If MUSTDELETE is true, delete previous nodes.
3307 
3309 {
3310  if (mustdelete) fPhysicalNodes->Delete();
3311  else fPhysicalNodes->Clear();
3312 }
3313 
3314 ////////////////////////////////////////////////////////////////////////////////
3315 /// Make an assembly of volumes.
3316 
3318 {
3319  return TGeoBuilder::Instance(this)->MakeVolumeAssembly(name);
3320 }
3321 
3322 ////////////////////////////////////////////////////////////////////////////////
3323 /// Make a TGeoVolumeMulti handling a list of volumes.
3324 
3326 {
3327  return TGeoBuilder::Instance(this)->MakeVolumeMulti(name, medium);
3328 }
3329 
3330 ////////////////////////////////////////////////////////////////////////////////
3331 /// Set type of exploding view (see TGeoPainter::SetExplodedView())
3332 
3334 {
3335  if ((ibomb>=0) && (ibomb<4)) fExplodedView = ibomb;
3336  if (fPainter) fPainter->SetExplodedView(ibomb);
3337 }
3338 
3339 ////////////////////////////////////////////////////////////////////////////////
3340 /// Set cut phi range
3341 
3343 {
3344  if ((phimin==0) && (phimax==360)) {
3345  fPhiCut = kFALSE;
3346  return;
3347  }
3348  fPhiCut = kTRUE;
3349  fPhimin = phimin;
3350  fPhimax = phimax;
3351 }
3352 
3353 ////////////////////////////////////////////////////////////////////////////////
3354 /// Set number of segments for approximating circles in drawing.
3355 
3357 {
3358  if (fNsegments==nseg) return;
3359  if (nseg>2) fNsegments = nseg;
3360  if (fPainter) fPainter->SetNsegments(nseg);
3361 }
3362 
3363 ////////////////////////////////////////////////////////////////////////////////
3364 /// Get number of segments approximating circles
3365 
3367 {
3368  return fNsegments;
3369 }
3370 
3371 ////////////////////////////////////////////////////////////////////////////////
3372 /// Now just a shortcut for GetElementTable.
3373 
3375 {
3376  GetElementTable();
3378 }
3379 
3380 ////////////////////////////////////////////////////////////////////////////////
3381 /// Returns material table. Creates it if not existing.
3382 
3384 {
3385  if (!fElementTable) fElementTable = new TGeoElementTable(200);
3386  return fElementTable;
3387 }
3388 
3389 ////////////////////////////////////////////////////////////////////////////////
3390 /// Make a rectiliniar step of length fStep from current point (fPoint) on current
3391 /// direction (fDirection). If the step is imposed by geometry, is_geom flag
3392 /// must be true (default). The cross flag specifies if the boundary should be
3393 /// crossed in case of a geometry step (default true). Returns new node after step.
3394 /// Set also on boundary condition.
3395 
3397 {
3398  return GetCurrentNavigator()->Step(is_geom, cross);
3399 }
3400 
3401 ////////////////////////////////////////////////////////////////////////////////
3402 /// shoot npoints randomly in a box of 1E-5 arround current point.
3403 /// return minimum distance to points outside
3404 
3406  const char* g3path)
3407 {
3408  return GetGeomPainter()->SamplePoints(npoints, dist, epsil, g3path);
3409 }
3410 
3411 ////////////////////////////////////////////////////////////////////////////////
3412 /// Set the top volume and corresponding node as starting point of the geometry.
3413 
3415 {
3416  if (fTopVolume==vol) return;
3417 
3418  TSeqCollection *brlist = gROOT->GetListOfBrowsers();
3419  TIter next(brlist);
3420  TBrowser *browser = 0;
3421 
3422  if (fTopVolume) fTopVolume->SetTitle("");
3423  fTopVolume = vol;
3424  vol->SetTitle("Top volume");
3425  if (fTopNode) {
3426  TGeoNode *topn = fTopNode;
3427  fTopNode = 0;
3428  while ((browser=(TBrowser*)next())) browser->RecursiveRemove(topn);
3429  delete topn;
3430  } else {
3431  fMasterVolume = vol;
3432  fMasterVolume->Grab();
3434  if (fgVerboseLevel>0) Info("SetTopVolume","Top volume is %s. Master volume is %s", fTopVolume->GetName(),
3435  fMasterVolume->GetName());
3436  }
3437 // fMasterVolume->FindMatrixOfDaughterVolume(vol);
3438 // fCurrentMatrix->Print();
3439  fTopNode = new TGeoNodeMatrix(vol, gGeoIdentity);
3440  fTopNode->SetName(TString::Format("%s_1",vol->GetName()));
3441  fTopNode->SetNumber(1);
3442  fTopNode->SetTitle("Top logical node");
3443  fNodes->AddAt(fTopNode, 0);
3444  if (!GetCurrentNavigator()) {
3446  return;
3447  }
3448  Int_t nnavigators = 0;
3450  if (!arr) return;
3451  nnavigators = arr->GetEntriesFast();
3452  for (Int_t i=0; i<nnavigators; i++) {
3453  TGeoNavigator *nav = (TGeoNavigator*)arr->At(i);
3454  nav->ResetAll();
3455  if (fClosed) nav->GetCache()->BuildInfoBranch();
3456  }
3457 }
3458 ////////////////////////////////////////////////////////////////////////////////
3459 /// Define different tracking media.
3460 /// printf("List of materials :\n");
3461 
3463 {
3464 /*
3465  Int_t nmat = fMaterials->GetSize();
3466  if (!nmat) {printf(" No materials !\n"); return;}
3467  Int_t *media = new Int_t[nmat];
3468  memset(media, 0, nmat*sizeof(Int_t));
3469  Int_t imedia = 1;
3470  TGeoMaterial *mat, *matref;
3471  mat = (TGeoMaterial*)fMaterials->At(0);
3472  if (mat->GetMedia()) {
3473  for (Int_t i=0; i<nmat; i++) {
3474  mat = (TGeoMaterial*)fMaterials->At(i);
3475  mat->Print();
3476  }
3477  return;
3478  }
3479  mat->SetMedia(imedia);
3480  media[0] = imedia++;
3481  mat->Print();
3482  for (Int_t i=0; i<nmat; i++) {
3483  mat = (TGeoMaterial*)fMaterials->At(i);
3484  for (Int_t j=0; j<i; j++) {
3485  matref = (TGeoMaterial*)fMaterials->At(j);
3486  if (mat->IsEq(matref)) {
3487  mat->SetMedia(media[j]);
3488  break;
3489  }
3490  if (j==(i-1)) {
3491  // different material
3492  mat->SetMedia(imedia);
3493  media[i] = imedia++;
3494  mat->Print();
3495  }
3496  }
3497  }
3498 */
3499 }
3500 
3501 ////////////////////////////////////////////////////////////////////////////////
3502 /// Check pushes and pulls needed to cross the next boundary with respect to the
3503 /// position given by FindNextBoundary. If radius is not mentioned the full bounding
3504 /// box will be sampled.
3505 
3507 {
3508  GetGeomPainter()->CheckBoundaryErrors(ntracks, radius);
3509 }
3510 
3511 ////////////////////////////////////////////////////////////////////////////////
3512 /// Check the boundary errors reference file created by CheckBoundaryErrors method.
3513 /// The shape for which the crossing failed is drawn with the starting point in red
3514 /// and the extrapolated point to boundary (+/- failing push/pull) in yellow.
3515 
3517 {
3519 }
3520 
3521 ////////////////////////////////////////////////////////////////////////////////
3522 /// Classify a given point. See TGeoChecker::CheckPoint().
3523 
3525 {
3526  GetGeomPainter()->CheckPoint(x,y,z,option);
3527 }
3528 
3529 ////////////////////////////////////////////////////////////////////////////////
3530 /// Test for shape navigation methods. Summary for test numbers:
3531 /// 1: DistFromInside/Outside. Sample points inside the shape. Generate
3532 /// directions randomly in cos(theta). Compute DistFromInside and move the
3533 /// point with bigger distance. Compute DistFromOutside back from new point.
3534 /// Plot d-(d1+d2)
3535 ///
3536 
3537 void TGeoManager::CheckShape(TGeoShape *shape, Int_t testNo, Int_t nsamples, Option_t *option)
3538 {
3539  GetGeomPainter()->CheckShape(shape, testNo, nsamples, option);
3540 }
3541 
3542 ////////////////////////////////////////////////////////////////////////////////
3543 /// Geometry checking.
3544 /// - if option contains 'o': Optional overlap checkings (by sampling and by mesh).
3545 /// - if option contains 'b': Optional boundary crossing check + timing per volume.
3546 ///
3547 /// STAGE 1: extensive overlap checking by sampling per volume. Stdout need to be
3548 /// checked by user to get report, then TGeoVolume::CheckOverlaps(0.01, "s") can
3549 /// be called for the suspicious volumes.
3550 /// STAGE2 : normal overlap checking using the shapes mesh - fills the list of
3551 /// overlaps.
3552 /// STAGE3 : shooting NRAYS rays from VERTEX and counting the total number of
3553 /// crossings per volume (rays propagated from boundary to boundary until
3554 /// geometry exit). Timing computed and results stored in a histo.
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 
3563 {
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 
3583 {
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 
3615 {
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 
3627 {
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 
3640 {
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*/)
3668 {
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 
3692 {
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)
3716 {
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 /// Lock current geometry so that no other geometry can be imported.
3760 
3762 {
3763  fgLock = kTRUE;
3764 }
3765 
3766 ////////////////////////////////////////////////////////////////////////////////
3767 /// Unlock current geometry.
3768 
3770 {
3771  fgLock = kFALSE;
3772 }
3773 
3774 ////////////////////////////////////////////////////////////////////////////////
3775 /// Check lock state.
3776 
3778 {
3779  return fgLock;
3780 }
3781 
3782 ////////////////////////////////////////////////////////////////////////////////
3783 /// Set verbosity level (static function).
3784 /// 0 - suppress messages related to geom-painter visibility level
3785 /// 1 - default value
3786 
3788 {
3789  return fgVerboseLevel;
3790 }
3791 
3792 ////////////////////////////////////////////////////////////////////////////////
3793 /// Return current verbosity level (static function).
3794 
3796 {
3797  fgVerboseLevel = vl;
3798 }
3799 
3800 ////////////////////////////////////////////////////////////////////////////////
3801 ///static function
3802 ///Import a geometry from a gdml or ROOT file
3803 ///
3804 /// -Case 1: gdml
3805 /// if filename ends with ".gdml" the foreign geometry described with gdml
3806 /// is imported executing some python scripts in $ROOTSYS/gdml.
3807 /// NOTE that to use this option, the PYTHONPATH must be defined like
3808 /// export PYTHONPATH=$ROOTSYS/lib:$ROOTSYS/gdml
3809 ///
3810 /// -Case 2: root file (.root) or root/xml file (.xml)
3811 /// Import in memory from filename the geometry with key=name.
3812 /// if name="" (default), the first TGeoManager object in the file is returned.
3813 ///
3814 ///Note that this function deletes the current gGeoManager (if one)
3815 ///before importing the new object.
3816 
3817 TGeoManager *TGeoManager::Import(const char *filename, const char *name, Option_t * /*option*/)
3818 {
3819  if (fgLock) {
3820  ::Warning("TGeoManager::Import", "TGeoMananager in lock mode. NOT IMPORTING new geometry");
3821  return NULL;
3822  }
3823  if (!filename) return 0;
3824  if (fgVerboseLevel>0) ::Info("TGeoManager::Import","Reading geometry from file: %s",filename);
3825 
3826  if (gGeoManager) delete gGeoManager;
3827  gGeoManager = 0;
3828 
3829  if (strstr(filename,".gdml")) {
3830  // import from a gdml file
3831  new TGeoManager("GDMLImport", "Geometry imported from GDML");
3832  TString cmd = TString::Format("TGDMLParse::StartGDML(\"%s\")", filename);
3833  TGeoVolume* world = (TGeoVolume*)gROOT->ProcessLineFast(cmd);
3834 
3835  if(world == 0) {
3836  ::Error("TGeoManager::Import", "Cannot open file");
3837  }
3838  else {
3839  gGeoManager->SetTopVolume(world);
3840  gGeoManager->CloseGeometry();
3841  gGeoManager->DefaultColors();
3842  }
3843  } else {
3844  // import from a root file
3845  TDirectory::TContext ctxt;
3846  // in case a web file is specified, use the cacheread option to cache
3847  // this file in the cache directory
3848  TFile *f = 0;
3849  if (strstr(filename,"http")) f = TFile::Open(filename,"CACHEREAD");
3850  else f = TFile::Open(filename);
3851  if (!f || f->IsZombie()) {
3852  ::Error("TGeoManager::Import", "Cannot open file");
3853  return 0;
3854  }
3855  if (name && strlen(name) > 0) {
3856  gGeoManager = (TGeoManager*)f->Get(name);
3857  } else {
3858  TIter next(f->GetListOfKeys());
3859  TKey *key;
3860  while ((key = (TKey*)next())) {
3861  if (strcmp(key->GetClassName(),"TGeoManager") != 0) continue;
3862  gGeoManager = (TGeoManager*)key->ReadObj();
3863  break;
3864  }
3865  }
3866  delete f;
3867  }
3868  if (!gGeoManager) return 0;
3869  if (!gROOT->GetListOfGeometries()->FindObject(gGeoManager)) gROOT->GetListOfGeometries()->Add(gGeoManager);
3870  if (!gROOT->GetListOfBrowsables()->FindObject(gGeoManager)) gROOT->GetListOfBrowsables()->Add(gGeoManager);
3871  gGeoManager->UpdateElements();
3872  return gGeoManager;
3873 }
3874 
3875 ////////////////////////////////////////////////////////////////////////////////
3876 /// Update element flags when geometry is loaded from a file.
3877 
3879 {
3880  if (!fElementTable) return;
3882  TGeoMaterial *mat;
3883  TGeoMixture *mix;
3884  TGeoElement *elem, *elem_table;
3885  Int_t i, nelem;
3886  while ((mat=(TGeoMaterial*)next())) {
3887  if (mat->IsMixture()) {
3888  mix = (TGeoMixture*)mat;
3889  nelem = mix->GetNelements();
3890  for (i=0; i<nelem; i++) {
3891  elem = mix->GetElement(i);
3892  if (!elem) continue;
3893  elem_table = fElementTable->GetElement(elem->Z());
3894  if (!elem_table) continue;
3895  if (elem != elem_table) {
3896  elem_table->SetDefined(elem->IsDefined());
3897  elem_table->SetUsed(elem->IsUsed());
3898  } else {
3899  elem_table->SetDefined();
3900  }
3901  }
3902  } else {
3903  elem = mat->GetElement();
3904  if (!elem) continue;
3905  elem_table = fElementTable->GetElement(elem->Z());
3906  if (!elem_table) continue;
3907  if (elem != elem_table) {
3908  elem_table->SetDefined(elem->IsDefined());
3909  elem_table->SetUsed(elem->IsUsed());
3910  } else {
3911  elem_table->SetUsed();
3912  }
3913  }
3914  }
3915 }
3916 
3917 ////////////////////////////////////////////////////////////////////////////////
3918 /// Initialize PNE array for fast access via index and unique-id.
3919 
3921 {
3922  if (fHashPNE) {
3923  fArrayPNE = new TObjArray(fHashPNE->GetSize());
3924  TIter next(fHashPNE);
3925  TObject *obj;
3926  while ((obj = next())) {
3927  fArrayPNE->Add(obj);
3928  }
3929  return kTRUE;
3930  }
3931  return kFALSE;
3932 }
3933 
3934 ////////////////////////////////////////////////////////////////////////////////
3935 /// Get time cut for drawing tracks.
3936 
3938 {
3939  tmin = fTmin;
3940  tmax = fTmax;
3941  return fTimeCut;
3942 }
3943 
3944 ////////////////////////////////////////////////////////////////////////////////
3945 /// Set time cut interval for drawing tracks. If called with no arguments, time
3946 /// cut will be disabled.
3947 
3949 {
3950  fTmin = tmin;
3951  fTmax = tmax;
3952  if (tmin==0 && tmax==999) fTimeCut = kFALSE;
3953  else fTimeCut = kTRUE;
3954  if (fTracks && !IsAnimatingTracks()) ModifiedPad();
3955 }
3956 
3957 ////////////////////////////////////////////////////////////////////////////////
3958 /// Convert coordinates from master volume frame to top.
3959 
3960 void TGeoManager::MasterToTop(const Double_t *master, Double_t *top) const
3961 {
3962  GetCurrentNavigator()->MasterToLocal(master, top);
3963 }
3964 
3965 ////////////////////////////////////////////////////////////////////////////////
3966 /// Convert coordinates from top volume frame to master.
3967 
3968 void TGeoManager::TopToMaster(const Double_t *top, Double_t *master) const
3969 {
3970  GetCurrentNavigator()->LocalToMaster(top, master);
3971 }
3972 
3973 ////////////////////////////////////////////////////////////////////////////////
3974 /// Create a parallel world for prioritized navigation. This can be populated
3975 /// with physical nodes and can be navigated independently using its API.
3976 /// In case the flag SetUseParallelWorldNav is set, any navigation query in the
3977 /// main geometry is checked against the parallel geometry, which gets priority
3978 /// in case of overlaps with the main geometry volumes.
3979 
3981 {
3982  fParallelWorld = new TGeoParallelWorld(name, this);
3983  return fParallelWorld;
3984 }
3985 
3986 ////////////////////////////////////////////////////////////////////////////////
3987 /// Activate/deactivate usage of parallel world navigation. Can only be done if
3988 /// there is a parallel world. Activating navigation will automatically close
3989 /// the parallel geometry.
3990 
3992 {
3993  if (!fParallelWorld) {
3994  Error("SetUseParallelWorldNav", "No parallel world geometry defined. Use CreateParallelWorld.");
3995  return;
3996  }
3997  if (!flag) {
3998  fUsePWNav = flag;
3999  return;
4000  }
4001  if (!fClosed) {
4002  Error("SetUseParallelWorldNav", "The geometry must be closed first");
4003  return;
4004  }
4005  // Closing the parallel world geometry is mandatory
4007 }
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:91
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:259
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:59
virtual void ClearThreadData() const
Definition: TGeoVolume.cxx:389
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:823
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual Int_t GetVisLevel() const =0
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 arround current point.
Bool_t IsRunTimeShape() const
Definition: TGeoShape.h:148
TList * fMedia
Definition: TGeoManager.h:100
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:92
Bool_t GotoSafeLevel()
Go upwards the tree until a non-overlaping node.
An array of TObjects.
Definition: TObjArray.h:39
virtual Int_t CountVisibleNodes()=0
TGeoHMatrix * fGLMatrix
Definition: TGeoManager.h:119
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.
TGeoVolumeAssembly * MakeVolumeAssembly(const char *name)
Make an assembly of volumes.
virtual void CreateThreadData(Int_t nthreads)
Definition: TGeoVolume.cxx:397
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:86
virtual void EditGeometry(Option_t *option="")=0
void Release()
Definition: TGeoVolume.h:156
void ClearAttributes()
Reset all attributes to default ones.
void Voxelize(Option_t *option)
build the voxels for this volume
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
virtual void ModifiedPad(Bool_t update=kFALSE) const =0
const char * GetPath() const
Get path to the current node in the form /node0/node1/...
void SetAllIndex()
Assigns uid'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 Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
Bool_t fMatrixTransform
flag that the list of physical nodes has to be drawn
Definition: TGeoManager.h:84
virtual void Sort(Int_t upto=kMaxInt)
If objects in array are sortable (i.e.
Definition: TObjArray.cxx:744
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
virtual Double_t * GetViewBox()=0
Ssiz_t Length() const
Definition: TString.h:390
virtual Bool_t IsVolumeMulti() const
Definition: TGeoVolume.h:131
TVector3 cross(const TVector3 &v1, const TVector3 &v2)
Definition: CsgOps.cxx:816
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.
Float_t theta
Definition: shapesAnim.C:5
void BombTranslation(const Double_t *tr, Double_t *bombtr)
Get the new 'bombed' 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
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 occurences 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:405
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-overlaping node.
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check all geometry for illegal overlaps within a limit OVLP.
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
virtual void Test(Int_t npoints, Option_t *option)=0
THashList * fHashVolumes
volume currently painted
Definition: TGeoManager.h:127
TVirtualGeoTrack * GetTrack(Int_t index)
Definition: TGeoManager.h:376
virtual void SetName(const char *name)
Change (i.e.
Definition: TNamed.cxx:128
virtual TList * GetListOfKeys() const
void Init()
Initialize manager class.
#define BIT(n)
Definition: Rtypes.h:120
TH1 * h
Definition: legend2.C:5
static Int_t fgMaxDaughters
Maximum level in geometry.
Definition: TGeoManager.h:52
virtual Int_t GetByteCount() const
get the total size in bytes for this volume
std::vector< double > values
Definition: TwoHistoFit2D.C:32
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:892
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:45
virtual Double_t Weight(Double_t precision, Option_t *option="v")=0
void SetVisBranch()
Set branch type visibility.
Definition: TGeoAtt.cxx:63
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:85
TVirtualGeoTrack * fCurrentTrack
Definition: TGeoManager.h:73
static const char * filename()
static void CreateDummyMedium()
Int_t fNtracks
Definition: TGeoManager.h:71
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:63
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:344
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:75
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:107
virtual void PrintOverlaps() const =0
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:141
Basic string class.
Definition: TString.h:137
static void ClearThreadsMap()
Clear the current map of threads.
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1075
TObjArray * fUniqueVolumes
Definition: TGeoManager.h:120
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:117
Bool_t fIsNodeSelectable
switch ON/OFF volume activity (default OFF - all volumes active))
Definition: TGeoManager.h:87
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:254
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:68
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:121
virtual void RandomPoints(const TGeoVolume *vol, Int_t npoints, Option_t *option="")=0
Bool_t fDrawExtra
Definition: TGeoManager.h:83
Float_t py
Definition: hprod.C:33
Int_t GetNAlignable(Bool_t with_uid=kFALSE) const
Retreives number of PN entries with or without UID.
TObjArray * fPdgNames
Definition: TGeoManager.h:97
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:102
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.
TFile * f
TObjArray * fArrayPNE
Definition: TGeoManager.h:130
TObjArray * fGShapes
Definition: TGeoManager.h:94
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
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:3851
Int_t CountNodes(Int_t nlevels=1000, Int_t option=0)
Count total number of subnodes starting from this volume, nlevels down option = 0 (default) - count o...
Definition: TGeoVolume.cxx:718
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:164
TObjArray * fOverlaps
Definition: TGeoManager.h:102
Int_t fNsegments
Definition: TGeoManager.h:70
virtual void SetClippingShape(TGeoShape *shape)=0
Int_t GetId() const
Bool_t fIsGeomCleaning
flag set when reading geometry
Definition: TGeoManager.h:80
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
TObjArray * fMatrices
current painter
Definition: TGeoManager.h:90
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:946
void CdNode(Int_t nodeid)
Change current path to point to the node having this id.
TGeoParallelWorld * fParallelWorld
Definition: TGeoManager.h:138
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:436
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 aligneable object with unique name corresponding to a path and adds it to the list of alig...
static Bool_t fgLock
Definition: TGeoManager.h:49
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:2321
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
void Class()
Definition: Class.C:29
void LocalToMaster(const Double_t *local, Double_t *master) const
Definition: TGeoManager.h:510
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:119
const int ny
Definition: kalman.C:17
void CleanGarbage()
Clean temporary volumes and shapes from garbage collection.
THashList * fHashGVolumes
hash list of volumes providing fast search
Definition: TGeoManager.h:128
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:62
static Bool_t IsLocked()
Check lock state.
THashList * fHashPNE
hash list of group volumes providing fast search
Definition: TGeoManager.h:129
void Browse(TBrowser *b)
Describe how to browse this object.
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:118
void SortOverlaps()
Sort overlaps by decreasing overlap distance. Extrusions comes first.
virtual Bool_t IsMixture() const
Definition: TGeoMaterial.h:127
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
TGeoNavigator * fCurrentNavigator
Lock existing navigators.
Definition: TGeoManager.h:114
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
if(pyself &&pyself!=Py_None)
static Int_t GetMaxDaughters()
Return maximum number of daughters of a volume used in the geometry.
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:116
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...
TH2D * h2
Definition: fit2dHist.C:45
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:104
Int_t fNPNEId
Definition: TGeoManager.h:132
virtual TGeoMatrix * GetMatrix() const =0
static Int_t fgNumThreads
Thread id's map.
Definition: TGeoManager.h:112
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:108
virtual TGeoElement * GetElement(Int_t i=0) const
Retreive the pointer to the element corresponding to component I.
virtual void CheckBoundaryReference(Int_t icheck=-1)=0
TGeoNode * GetCurrentNode() const
Definition: TGeoManager.h:486
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:918
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:81
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition: TClass.cxx:5426
TH1F * h1
Definition: legend1.C:5
NavigatorsMap_t fNavigators
Definition: TGeoManager.h:110
Bool_t fIsGeomReading
Definition: TGeoManager.h:79
Int_t fVisLevel
Definition: TGeoManager.h:69
Float_t z[5]
Definition: Ifit.C:16
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 paralelipiped 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
Retreive 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:50
TVirtualGeoTrack * GetMother() const
char * out
Definition: TBase64.cxx:29
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:135
Int_t * fKeyPNEId
Definition: TGeoManager.h:133
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:77
TGeoMaterial * FindDuplicateMaterial(const TGeoMaterial *mat) const
Find if a given material duplicates an existing one.
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition: TObject.cxx:743
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
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.
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:61
void RemoveNavigator(const TGeoNavigator *nav)
Clear a single navigator.
TObjArray * fPhysicalNodes
Definition: TGeoManager.h:93
virtual Int_t GetNelements() const
Definition: TGeoMaterial.h:195
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
Bool_t fTimeCut
Definition: TGeoManager.h:82
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:1135
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:194
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:124
Int_t fNLevel
array of node id's
Definition: TGeoManager.h:125
void SetNeedRebuild(Bool_t flag=kTRUE)
TThread * t[5]
Definition: threadsh1.C:13
void Clear(Option_t *option="")
Remove all objects from the list.
Definition: THashList.cxx:168
virtual void AfterStreamer()
Definition: TGeoShape.h:104
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:40
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
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
Definition: TGeoNode.cxx:211
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Definition: TObjArray.cxx:222
TGeoPNEntry * GetAlignableEntry(const char *name) const
Retreives 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 'mat<index>'.
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
ROOT::R::TRInterface & r
Definition: Object.C:4
TGeoVolume * MakePara(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz, Double_t alpha, Double_t theta, Double_t phi)
Make in one step a volume pointing to a paralelipiped 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.
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)...
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
void SaveAttributes(std::ostream &out)
save attributes for this node
Definition: TGeoNode.cxx:436
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:67
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:494
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 ...
virtual void GetBombFactors(Double_t &bombx, Double_t &bomby, Double_t &bombz, Double_t &bombr) const =0
static Int_t fgMaxLevel
Verbosity level for Info messages (no IO).
Definition: TGeoManager.h:51
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:60
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:825
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:173
Int_t fMaxVisNodes
Definition: TGeoManager.h:72
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:393
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Definition: TGeoMatrix.cxx:532
virtual void SetCheckedNode(TGeoNode *node)=0
Double_t E()
Definition: TMath.h:54
Int_t fNpdg
current track
Definition: TGeoManager.h:74
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TObjArray * fTracks
list of runtime volumes
Definition: TGeoManager.h:96
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
Definition: TString.cxx:1056
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:66
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:99
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:134
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 ovelaps. 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:78
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)
Long64_t entry
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:101
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:95
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-overlaping node.
Float_t phi
Definition: shapesAnim.C:6
void SetOverlapping(Bool_t flag=kTRUE)
Definition: TGeoNode.h:127
TGeoVolume * fCurrentVolume
current navigator
Definition: TGeoManager.h:115
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 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
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:525
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
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.
Definition: TROOT.cxx:399
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-overlaping node.
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
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:88
virtual Bool_t IsComposite() const
Definition: TGeoShape.h:140
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:439
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
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
void dir(char *path=0)
Definition: rootalias.C:30
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:113
TObjArray * GetListOfPhysicalNodes()
Definition: TGeoManager.h:460
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.
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
Flag for multi-threading.
Definition: TGeoManager.h:137
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:76
Bool_t IsAnimatingTracks() const
Definition: TGeoManager.h:388
void SetTminTmax(Double_t tmin=0, Double_t tmax=999)
Set time cut interval for drawing tracks.
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.
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's and navigator arrays.
Definition: TGeoManager.h:111
virtual void SetLineColor(Color_t lcolor)
Set the line color.
void SetVolume(TGeoVolume *volume)
Definition: TGeoNode.h:124
#define name(a, b)
Definition: linkTestLib0.cpp:5
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.
virtual void CheckBoundaryErrors(Int_t ntracks=1000000, Double_t radius=-1.)=0
virtual Double_t GetZ() const
Definition: TGeoMaterial.h:104
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:58
TGeoNode * FindNextBoundary(Double_t stepmax=TGeoShape::Big(), const char *path="", Bool_t frombdr=kFALSE)
Find distance to next boundary and store it in fStep.
void CdNext()
Do a cd to the node found next by FindNextBoundary.
Float_t px
Definition: hprod.C:33
void CountLevels()
Count maximum number of nodes per volume, maximum depth and maximum number of xtru vertices...
void ClearOverlaps()
Clear the list of overlaps.
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:335
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:466
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:122
Bool_t TestShapeBit(UInt_t f) const
Definition: TGeoShape.h:172
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 phisical node entries
Definition: TGeoManager.h:131
virtual Double_t GetDensity() const
Definition: TGeoMaterial.h:106
void InspectState() const
Inspects path and all flags for the current state.
static TGeoBuilder * Instance(TGeoManager *geom)
Return pointer to singleton.
Definition: TGeoBuilder.cxx:94
virtual void Add(TObject *obj)
Definition: TList.h:81
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:133
TGeoMedium * GetMedium() const
Definition: TGeoVolume.h:189
void xtru()
Definition: geodemo.C:1561
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
Retreives an existing alignable object having a preset UID.
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:534
void Matrix(Int_t index, Double_t theta1, Double_t phi1, Double_t theta2, Double_t phi2, Double_t theta3, Double_t phi3)
Create rotation matrix named 'mat<index>'.
TGeoVolume * 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:288
Bool_t fMultiThread
Max number of threads.
Definition: TGeoManager.h:136
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:103
TString fParticleName
path to current node
Definition: TGeoManager.h:65
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:686
static Int_t GetMaxXtruVert()
Return maximum number of vertices for an xtru shape used.
Definition: Rtypes.h:61
TGeoVolume * fPaintVolume
Definition: TGeoManager.h:126
void ResetBit(UInt_t f)
Definition: TObject.h:172
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 prioritized navigation.
void FindOverlaps() const
loop all nodes marked as overlaps and find overlaping brothers
virtual Int_t IndexOf(const TObject *obj) const
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 'unbombed' 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:99
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:127
TGeoVolume * fMasterVolume
top physical node
Definition: TGeoManager.h:118
void SetNumber(Int_t number)
Definition: TGeoVolume.h:248
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
TObject * obj
virtual Int_t GetByteCount() const
Get total size in bytes of this.
Definition: TGeoMatrix.cxx:289
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 : option=0 (default) all nodes drawn down to vislevel option=1 leaves and nodes at v...
tuple all
Definition: na49view.py:13
TVirtualGeoPainter * GetGeomPainter()
Make a default painter if none present. Returns pointer to it.
Bool_t OptimizeVoxels()
Perform an exensive 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:944
Definition: Rtypes.h:62
void BuildInfoBranch()
Bulds info branch. Navigation is possible only after this step.
Definition: TGeoCache.cxx:150
TGeoVolume * MakePcon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nz)
Make in one step a volume pointing to a polycone shape with given medium.
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute mouse actions on this manager.
void SetNumber(Int_t number)
Definition: TGeoNode.h:125
virtual Int_t GetByteCount() const
Definition: TGeoMaterial.h:102
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:364
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:53
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:904