Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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");
21  gGeoManager->DefaultColors();
22  gGeoManager->SetMaxVisNodes(40000);
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 }