Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
geom_alice_its.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Shows geometry of ALICE ITS.
4///
5/// \image html eve_geom_alice_its.png
6/// \macro_code
7///
8/// \author Matevz Tadel
9
10#include "TEveManager.h"
11#include "TEveGeoNode.h"
12
13#include "TGeoManager.h"
14#include "TGeoNode.h"
15#include "TGeoVolume.h"
16#include "TGeoMedium.h"
17
18#include "TString.h"
19
20void geom_alice_its()
21{
23
24 gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/alice.root");
25
26 TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("ITSV_1");
29
31}
32
33
34//==============================================================================
35// Demonstrate extraction of volumes matching certain criteria.
36//==============================================================================
37
38// Should be run in compiled mode -- CINT has issues with recursion.
39//
40// 1. Creation:
41// root
42// .L geom_alice_its.C+
43// extract_ssd_modules()
44// .q
45// This creates file "test-extract.root" in current dir.
46//
47// 2. Viewing:
48// root
49// .x show_extract.C("test-extract.root")
50
51TEveGeoNode* descend_extract(TGeoNode* node)
52{
53 // We only return something if:
54 // - this is a node of interest;
55 // - one of the daughters returns something of interest.
56
57 const TString material("ITS_SI$");
58
59 TEveGeoNode *res = 0;
60
61 auto medium = node->GetVolume()->GetMedium();
62 if (medium && material == medium->GetName()) {
63 // Node of interest - instantiate eve representation and return.
64 res = new TEveGeoNode(node);
65 return res;
66 }
67
68 Int_t nd = node->GetNdaughters();
69 for (Int_t i = 0; i < nd; ++i) {
70 auto ed = descend_extract(node->GetDaughter(i));
71
72 if (ed) {
73 if (res == 0) res = new TEveGeoNode(node);
74 res->AddElement(ed);
75 }
76 }
77
78 return res;
79}
80
81void extract_ssd_modules()
82{
83 const TString kEH("extract_ssd_modules");
84
86
87 gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/alice.root");
88
89 Bool_t s = gGeoManager->cd("/ITSV_1/ITSD_1/IT56_1");
90 if (!s) {
91 Error(kEH, "Start node not found.");
92 return;
93 }
94
95 auto node = gGeoManager->GetCurrentNode();
96
97 TEveGeoNode *egn = descend_extract(node);
98
99 if (egn == 0) {
100 Warning(kEH, "No matching nodes found.");
101 return;
102 }
103
104 egn->SaveExtract("test-extract.root", "AliSDD", kTRUE);
105}
int Int_t
Definition RtypesCore.h:45
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:100
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:231
R__EXTERN TEveManager * gEve
R__EXTERN TGeoManager * gGeoManager
virtual void AddElement(TEveElement *el)
Add el to the list of children.
Wrapper for TGeoNode that allows it to be shown in GUI and controlled as a TEveElement.
Definition TEveGeoNode.h:30
void SaveExtract(const char *file, const char *name, Bool_t leafs_only)
Save the shape tree as TEveGeoShapeExtract.
A wrapper over a TGeoNode, possibly displaced with a global trasformation stored in TEveElement.
Definition TEveGeoNode.h:90
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
TGeoManager * GetGeometry(const TString &filename)
Get geometry with given filename.
virtual Bool_t cd(const char *path="")
Browse the tree of nodes starting from fTopNode according to pathname.
TGeoNode * GetCurrentNode() const
TGeoVolume * GetTopVolume() const
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:41
TGeoVolume * GetVolume() const
Definition TGeoNode.h:97
Int_t GetNdaughters() const
Definition TGeoNode.h:93
TGeoNode * GetDaughter(Int_t ind) const
Definition TGeoNode.h:85
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:174
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
Basic string class.
Definition TString.h:136