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__)
36 #include <Riostream.h>
37 #include <TObjArray.h>
39 #include <TGeoManager.h>
40 #include <TGeoVolume.h>
47 /// Set all volumes invisible
49 TObjArray* volumes = gGeoManager->GetListOfVolumes();
50 for (Int_t i=0; i<volumes->GetEntriesFast(); i++)
51 ((TGeoVolume*)volumes->At(i))->SetVisibility(kFALSE);
56 void setVisibility(const TString& volumeName, Bool_t visibility= kTRUE)
58 /// Set visibility to the volume specified by name
60 TGeoVolume* volume = gGeoManager->FindVolumeFast(volumeName.Data());
63 cerr << "Volume " << volumeName.Data() << " not found." << endl;
67 volume->SetVisibility(visibility);
70 void setDaughtersVisibility(const TString& volumeName, Bool_t visibility= kTRUE)
72 /// Set visibility to daughter of the volume specified by name.
73 /// If the daughter volume is an assembly the visibility setting
74 /// is propagated to its real volumes daughters.
76 TGeoVolume* volume = gGeoManager->FindVolumeFast(volumeName.Data());
79 cerr << "Volume " << volumeName.Data() << " not found." << endl;
83 //for ( Int_t i=0; i<10; i++ ) {
85 for ( Int_t i=0; i<volume->GetNdaughters(); i++ ) {
87 TGeoVolume* dvolume = volume->GetNode(i)->GetVolume();
88 if ( dvolume->IsAssembly() ) {
89 // Do no set visibility to assembly but to its daughters
90 setDaughtersVisibility(dvolume->GetName(), visibility);
93 cout << "Setting visibility to " << dvolume->GetName() << endl;
94 dvolume->SetVisibility(visibility);
98 if ( colourNo > 9 ) colourNo = 1;
99 dvolume->SetLineColor(colourNo);
104 void buildGeometry(Bool_t allVisible = kFALSE )
106 /// Build the ideal geometry, make all volumes
108 AliMpCDB::LoadMpSegmentation2();
109 gAlice->Init("$ALICE_ROOT/MUON/Config.C");
113 if ( ! allVisible ) visibilityOff();
115 gGeoManager->SetVisLevel(10);
116 gGeoManager->GetTopVolume()->SetVisContainers(kTRUE);
117 gGeoManager->GetTopVolume()->Draw("ogl");
120 cout << "You can now add volumes in the scene: " << endl;
121 cout << " setVisibility(\"MyVolume\") " << endl;
122 cout << " setDaughtersVisibility(\"MyVolume\") " << endl;;
123 cout << "or remove them from the scene: " << endl;
124 cout << " setVisibility(\"MyVolume\", kFALSE);" << endl;
125 cout << " setDaughtersVisibility(\"MyVolume\", kFALSE);" << endl;