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/files/alice.root");
25
26 TGeoNode *node = gGeoManager->GetTopVolume()->FindNode("ITSV_1");
29
31}
32
33//==============================================================================
34// Demonstrate extraction of volumes matching certain criteria.
35//==============================================================================
36
37// Should be run in compiled mode -- CINT has issues with recursion.
38//
39// 1. Creation:
40// root
41// .L geom_alice_its.C+
42// extract_ssd_modules()
43// .q
44// This creates file "test-extract.root" in current dir.
45//
46// 2. Viewing:
47// root
48// .x show_extract.C("test-extract.root")
49
51{
52 // We only return something if:
53 // - this is a node of interest;
54 // - one of the daughters returns something of interest.
55
56 const TString material("ITS_SI$");
57
58 TEveGeoNode *res = nullptr;
59
60 auto medium = node->GetVolume()->GetMedium();
61 if (medium && material == medium->GetName()) {
62 // Node of interest - instantiate eve representation and return.
63 res = new TEveGeoNode(node);
64 return res;
65 }
66
67 Int_t nd = node->GetNdaughters();
68 for (Int_t i = 0; i < nd; ++i) {
69 auto ed = descend_extract(node->GetDaughter(i));
70
71 if (ed) {
72 if (res == nullptr)
73 res = new TEveGeoNode(node);
74 res->AddElement(ed);
75 }
76 }
77
78 return res;
79}
80
82{
83 const TString kEH("extract_ssd_modules");
84
86
87 gGeoManager = gEve->GetGeometry("http://root.cern/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
98
99 if (egn == nullptr) {
100 Warning(kEH, "No matching nodes found.");
101 return;
102 }
103
104 egn->SaveExtract("test-extract.root", "AliSDD", kTRUE);
105}
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
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
A wrapper over a TGeoNode, possibly displaced with a global trasformation stored in TEveElement.
Definition TEveGeoNode.h:90
void AddGlobalElement(TEveElement *element, TEveElement *parent=nullptr)
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:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
Int_t GetNdaughters() const
Definition TGeoNode.h:91
TGeoNode * GetDaughter(Int_t ind) const
Definition TGeoNode.h:83
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:175
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
Basic string class.
Definition TString.h:139