AliRoot Core  99e027a (99e027a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MUONGenerateGentleGeometry.C
Go to the documentation of this file.
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 //
31 
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 
45 void AddNodes(TGeoNode *node, TEveGeoNode *parent, Int_t depth, Int_t depthmax,
46  TObjArray *list);
47 
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 //_____________________________________________________________________________
86 void AddNodes(TGeoNode *node, TEveGeoNode *parent, Int_t depth, Int_t depthmax,
87  TObjArray *list)
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  {
101  TGeoNode *node2 = (TGeoNode*) nlist->At(in);
102  TEveGeoNode *son;
103  if (strcmp(node2->GetName(),sname.Data()) == 0)
104  {
105  son = dynamic_cast<TEveGeoNode*>(parent->FindChild(nname->GetName()));
106  if (!son)
107  {
108  son = new TEveGeoNode(node2);
109  parent->AddElement(son);
110  }
111  } else {
112  continue;
113  }
114  AddNodes(node2,son, depth, depthmax, list);
115  }
116 
117 }
void MUONGenerateGentleGeometry()
#define TObjArray
void AddNodes(TGeoNode *node, TEveGeoNode *parent, Int_t depth, Int_t depthmax, TObjArray *list)