Logo ROOT   6.14/05
Reference Guide
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 /// \macro_code
13 ///
14 /// \authors Bertrand Bellenot, Rene Brun
15 
16 void RecursiveInvisible(TGeoVolume *vol);
17 void RecursiveTransparency(TGeoVolume *vol, Int_t transp);
18 
19 void geomD0(Int_t allVisible=0) {
20  TGeoManager::Import("http://root.cern.ch/files/d0.root");
23  //gGeoManager->SetVisLevel(4);
24  if (!allVisible) {
25  RecursiveInvisible(gGeoManager->GetVolume("D0-"));
26  RecursiveInvisible(gGeoManager->GetVolume("D0+"));
27  RecursiveInvisible(gGeoManager->GetVolume("D0WZ"));
28  RecursiveInvisible(gGeoManager->GetVolume("D0WL"));
29  RecursiveTransparency(gGeoManager->GetVolume("MUON"), 90);
30  }
31 
32  gGeoManager->GetVolume("D0")->Draw("ogl");
33 }
34 
35 void RecursiveInvisible(TGeoVolume *vol)
36 {
37  vol->InvisibleAll();
38  Int_t nd = vol->GetNdaughters();
39  for (Int_t i=0; i<nd; i++) {
40  RecursiveInvisible(vol->GetNode(i)->GetVolume());
41  }
42 }
43 
44 void RecursiveTransparency(TGeoVolume *vol, Int_t transp)
45 {
46  vol->SetTransparency(transp);
47  Int_t nd = vol->GetNdaughters();
48  for (Int_t i=0; i<nd; i++) {
49  RecursiveTransparency(vol->GetNode(i)->GetVolume(), transp);
50  }
51 }
TGeoNode * GetNode(const char *name) const
get the pointer to a daughter node
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition: TGeoVolume.h:48
virtual void Draw(Option_t *option="")
draw top volume according to option
TGeoVolume * GetVolume(const char *name) const
Search for a named volume. All trailing blanks stripped.
int Int_t
Definition: RtypesCore.h:41
Int_t GetNdaughters() const
Definition: TGeoVolume.h:350
void InvisibleAll(Bool_t flag=kTRUE)
Make volume and each of it daughters (in)visible.
Definition: TGeoVolume.cxx:816
void SetMaxVisNodes(Int_t maxnodes=10000)
set the maximum number of visible nodes.
void DefaultColors()
Set default volume colors according to A of material.
void SetTransparency(Char_t transparency=0)
Definition: TGeoVolume.h:220
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:562
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
Definition: TGeoNode.h:94