1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 /// \file MUONGeometryViewingHelper.C
20 /// \brief Macro providing methods helping in viewing geometry
22 /// To be run from aliroot:
24 /// root[0] .x MUONGeometryViewingHelper.C
25 /// root[0] buildGeometry();
28 /// \author: I. Hrivnacova, IPN Orsay
30 #if !defined(__CINT__) || defined(__MAKECINT__)
32 #include <Riostream.h>
33 #include <TObjArray.h>
35 #include <TGeoManager.h>
36 #include <TGeoVolume.h>
43 /// Set all volumes invisible
45 TObjArray* volumes = gGeoManager->GetListOfVolumes();
46 for (Int_t i=0; i<volumes->GetEntriesFast(); i++) {
47 if ( !((TGeoVolume*)volumes->At(i))->IsAssembly() )
48 ((TGeoVolume*)volumes->At(i))->SetVisibility(kFALSE);
54 void setVisibility(const TString& volumeName, Bool_t visibility= kTRUE)
56 /// Set visibility to the volume specified by name
58 TGeoVolume* volume = gGeoManager->FindVolumeFast(volumeName.Data());
61 cerr << "Volume " << volumeName.Data() << " not found." << endl;
65 volume->SetVisibility(visibility);
68 void setDaughtersVisibility(const TString& volumeName, Bool_t visibility= kTRUE)
70 /// Set visibility to daughter of the volume specified by name.
71 /// If the daughter volume is an assembly the visibility setting
72 /// is propagated to its real volumes daughters.
74 TGeoVolume* volume = gGeoManager->FindVolumeFast(volumeName.Data());
77 cerr << "Volume " << volumeName.Data() << " not found." << endl;
81 //for ( Int_t i=0; i<10; i++ ) {
83 for ( Int_t i=0; i<volume->GetNdaughters(); i++ ) {
85 TGeoVolume* dvolume = volume->GetNode(i)->GetVolume();
86 if ( dvolume->IsAssembly() ) {
87 // Do no set visibility to assembly but to its daughters
88 setDaughtersVisibility(dvolume->GetName(), visibility);
91 cout << "Setting visibility to " << dvolume->GetName() << endl;
92 dvolume->SetVisibility(visibility);
96 if ( colourNo > 9 ) colourNo = 1;
97 dvolume->SetLineColor(colourNo);
102 void buildGeometry(Bool_t allVisible = kFALSE )
104 /// Load geometry from the file, make all volumes invisible
106 TGeoManager::Import("geometry.root");
110 if ( ! allVisible ) visibilityOff();
112 gGeoManager->SetVisLevel(10);
113 gGeoManager->GetTopVolume()->SetVisContainers(kTRUE);
114 gGeoManager->GetTopVolume()->Draw("ogl");
117 cout << "You can now add volumes in the scene: " << endl;
118 cout << " setVisibility(\"MyVolume\") " << endl;
119 cout << " setDaughtersVisibility(\"MyVolume\") " << endl;;
120 cout << "or remove them from the scene: " << endl;
121 cout << " setVisibility(\"MyVolume\", kFALSE);" << endl;
122 cout << " setDaughtersVisibility(\"MyVolume\", kFALSE);" << endl;