]>
Commit | Line | Data |
---|---|---|
d0420264 | 1 | /// \ingroup macros |
2 | /// \file MUONGenerateGentleGeometry.C | |
3 | /// \brief Macro for generating a simplified geometry used by the | |
4 | /// event display alieve. The generated file gentle_geo_muon.root | |
5 | /// must be placed in EVE/alice-data/. The input is the sensitive | |
6 | /// volumes list file svmap.dat and the geometry file geometry.root | |
7 | /// | |
8 | /// To be run from aliroot: | |
9 | /// | |
10 | /// .x MUONGenerateGentleGeometry.C | |
11 | /// | |
12 | /// | |
13 | /// \author: M. Tadel, CERN and B. Vulpescu LPC, Clermont-Ferrand | |
14 | ||
15 | void MUONGenerateGentleGeometry() { | |
16 | ||
17 | gSystem->Load("libGeom"); | |
18 | ||
19 | TEveManager::Create(); | |
20 | ||
21 | TGeoManager::Import("geometry.root"); | |
22 | TGeoNode* tnode = gGeoManager->GetTopNode(); | |
23 | TEveGeoTopNode* eve_tnode = new TEveGeoTopNode(gGeoManager, tnode); | |
24 | tnode->SetVisibility(kFALSE); | |
25 | eve_tnode->SetVisLevel(0); | |
26 | ||
27 | gEve->AddGlobalElement(eve_tnode); | |
28 | ||
29 | TString path; | |
30 | TObjArray *list; | |
31 | Int_t depth; | |
32 | ||
33 | Char_t line[256]; | |
34 | ifstream in("data/svmap.dat", ios::in); | |
35 | ||
36 | while (!in.eof()) { | |
37 | ||
38 | in >> line; | |
39 | ||
40 | path = TString(line); | |
41 | if (!path.Contains("ALIC")) continue; | |
42 | ||
43 | list = path.Tokenize("/"); | |
44 | depth = list->GetEntries(); | |
45 | AddNodes(tnode,eve_tnode,depth,depth,list); | |
46 | } | |
47 | ||
48 | eve_tnode->SaveExtract("gentle_geo_muon.root", "Gentle MUON", kTRUE); | |
49 | ||
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | void AddNodes(TGeoNode *node, TEveGeoNode *parent, Int_t depth, Int_t depthmax, TObjArray *list) | |
54 | { | |
55 | if (--depth <= 0) | |
56 | return; | |
57 | ||
58 | TObjString *nname = (TObjString*)list->At(depthmax-depth); | |
59 | TString sname = nname->GetString(); | |
60 | ||
61 | TObjArray *nlist = node->GetVolume()->GetNodes(); | |
62 | if (nlist == 0x0) return; | |
63 | Int_t nNodes = nlist->GetEntries(); | |
64 | ||
65 | for (Int_t in = 0; in < nNodes; in++) | |
66 | { | |
67 | TGeoNode *node = (TGeoNode*) nlist->At(in); | |
68 | TEveGeoNode *son; | |
69 | if (strcmp(node->GetName(),sname.Data()) == 0) | |
70 | { | |
71 | son = dynamic_cast<TEveGeoNode*>(parent->FindChild(nname->GetName())); | |
72 | if (!son) | |
73 | { | |
74 | son = new TEveGeoNode(node); | |
75 | parent->AddElement(son); | |
76 | } | |
77 | } else { | |
78 | continue; | |
79 | } | |
80 | AddNodes(node,son, depth, depthmax, list); | |
81 | } | |
82 | ||
83 | } |