o add Reset function to CalPad and CalROC o Add functionality to AliTPCdataQA - Reset...
[u/mrichter/AliRoot.git] / MUON / MUONGenerateGentleGeometry.C
CommitLineData
052e193b 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16// $Id$
17//
d0420264 18/// \ingroup macros
19/// \file MUONGenerateGentleGeometry.C
20/// \brief Macro for generating a simplified geometry used by the
21/// event display alieve. The generated file gentle_geo_muon.root
22/// must be placed in EVE/alice-data/. The input is the sensitive
23/// volumes list file svmap.dat and the geometry file geometry.root
24///
25/// To be run from aliroot:
26///
27/// .x MUONGenerateGentleGeometry.C
28///
29///
30/// \author: M. Tadel, CERN and B. Vulpescu LPC, Clermont-Ferrand
31
052e193b 32#if !defined(__CINT__) || defined(__MAKECINT__)
33
34#include <TSystem.h>
35#include <TEveManager.h>
36#include <TEveGeoNode.h>
37#include <TGeoManager.h>
38#include <TGeoNode.h>
39#include <TString.h>
40#include <TObjArray.h>
41#include <Riostream.h>
42
43#endif
44
45void AddNodes(TGeoNode *node, TEveGeoNode *parent, Int_t depth, Int_t depthmax,
46 TObjArray *list);
47
d0420264 48void MUONGenerateGentleGeometry() {
49
50 gSystem->Load("libGeom");
51
52 TEveManager::Create();
53
54 TGeoManager::Import("geometry.root");
55 TGeoNode* tnode = gGeoManager->GetTopNode();
56 TEveGeoTopNode* eve_tnode = new TEveGeoTopNode(gGeoManager, tnode);
57 tnode->SetVisibility(kFALSE);
58 eve_tnode->SetVisLevel(0);
59
60 gEve->AddGlobalElement(eve_tnode);
61
62 TString path;
63 TObjArray *list;
64 Int_t depth;
65
66 Char_t line[256];
67 ifstream in("data/svmap.dat", ios::in);
68
69 while (!in.eof()) {
70
71 in >> line;
72
73 path = TString(line);
74 if (!path.Contains("ALIC")) continue;
75
76 list = path.Tokenize("/");
77 depth = list->GetEntries();
78 AddNodes(tnode,eve_tnode,depth,depth,list);
79 }
80
81 eve_tnode->SaveExtract("gentle_geo_muon.root", "Gentle MUON", kTRUE);
82
83}
84
85//_____________________________________________________________________________
052e193b 86void AddNodes(TGeoNode *node, TEveGeoNode *parent, Int_t depth, Int_t depthmax,
87 TObjArray *list)
d0420264 88{
89 if (--depth <= 0)
90 return;
91
92 TObjString *nname = (TObjString*)list->At(depthmax-depth);
93 TString sname = nname->GetString();
94
95 TObjArray *nlist = node->GetVolume()->GetNodes();
96 if (nlist == 0x0) return;
97 Int_t nNodes = nlist->GetEntries();
98
99 for (Int_t in = 0; in < nNodes; in++)
100 {
052e193b 101 TGeoNode *node2 = (TGeoNode*) nlist->At(in);
d0420264 102 TEveGeoNode *son;
052e193b 103 if (strcmp(node2->GetName(),sname.Data()) == 0)
d0420264 104 {
105 son = dynamic_cast<TEveGeoNode*>(parent->FindChild(nname->GetName()));
106 if (!son)
107 {
052e193b 108 son = new TEveGeoNode(node2);
d0420264 109 parent->AddElement(son);
110 }
111 } else {
112 continue;
113 }
052e193b 114 AddNodes(node2,son, depth, depthmax, list);
d0420264 115 }
116
117}