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