Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
geomD0.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Script drawing a detector geometry (here D0).
4///
5/// by default the geometry is drawn using the GL viewer
6/// Using the TBrowser, you can select other components
7/// if the file containing the geometry is not found in the local
8/// directory, it is automatically read from the ROOT web site.
9/// - run with `.x geomD0.C` top level detectors are transparent
10/// - or `.x geomD0.C(1)` top level detectors are visible
11///
12/// \image html geom_geomD0.png width=800px
13/// \macro_code
14///
15/// \authors Bertrand Bellenot, Rene Brun
16
17void RecursiveInvisible(TGeoVolume *vol);
18void RecursiveTransparency(TGeoVolume *vol, Int_t transp);
19
20void geomD0(Int_t allVisible = 0)
21{
22 TGeoManager::Import("http://root.cern/files/d0.root");
25 // gGeoManager->SetVisLevel(4);
26 if (!allVisible) {
27 RecursiveInvisible(gGeoManager->GetVolume("D0-"));
28 RecursiveInvisible(gGeoManager->GetVolume("D0+"));
29 RecursiveInvisible(gGeoManager->GetVolume("D0WZ"));
30 RecursiveInvisible(gGeoManager->GetVolume("D0WL"));
31 RecursiveTransparency(gGeoManager->GetVolume("MUON"), 90);
32 }
33
34 gGeoManager->GetVolume("D0")->Draw("ogl");
35}
36
37void RecursiveInvisible(TGeoVolume *vol)
38{
39 vol->InvisibleAll();
40 Int_t nd = vol->GetNdaughters();
41 for (Int_t i = 0; i < nd; i++) {
42 RecursiveInvisible(vol->GetNode(i)->GetVolume());
43 }
44}
45
46void RecursiveTransparency(TGeoVolume *vol, Int_t transp)
47{
48 vol->SetTransparency(transp);
49 Int_t nd = vol->GetNdaughters();
50 for (Int_t i = 0; i < nd; i++) {
51 RecursiveTransparency(vol->GetNode(i)->GetVolume(), transp);
52 }
53}
int Int_t
Definition RtypesCore.h:45
R__EXTERN TGeoManager * gGeoManager
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
void DefaultColors()
Set default volume colors according to A of material.
void SetMaxVisNodes(Int_t maxnodes=10000)
set the maximum number of visible nodes.
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
void Draw(Option_t *option="") override
draw top volume according to option
Int_t GetNdaughters() const
Definition TGeoVolume.h:362
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:376
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
void InvisibleAll(Bool_t flag=kTRUE)
Make volume and each of it daughters (in)visible.