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//
38// 1. Creation:
39// root
40// .L geom_alice_its.C+
41// extract_ssd_modules()
42// .q
43// This creates file "test-extract.root" in current dir.
44//
45// 2. Viewing:
46// root
47// .x show_extract.C("test-extract.root")
48
50{
51 // We only return something if:
52 // - this is a node of interest;
53 // - one of the daughters returns something of interest.
54
55 const TString material("ITS_SI$");
56
57 TEveGeoNode *res = nullptr;
58
59 auto medium = node->GetVolume()->GetMedium();
60 if (medium && material == medium->GetName()) {
61 // Node of interest - instantiate eve representation and return.
62 res = new TEveGeoNode(node);
63 return res;
64 }
65
66 Int_t nd = node->GetNdaughters();
67 for (Int_t i = 0; i < nd; ++i) {
68 auto ed = descend_extract(node->GetDaughter(i));
69
70 if (ed) {
71 if (res == nullptr)
72 res = new TEveGeoNode(node);
73 res->AddElement(ed);
74 }
75 }
76
77 return res;
78}
79
81{
82 const TString kEH("extract_ssd_modules");
83
85
86 gGeoManager = gEve->GetGeometry("http://root.cern/files/alice.root");
87
88 Bool_t s = gGeoManager->cd("/ITSV_1/ITSD_1/IT56_1");
89 if (!s) {
90 Error(kEH, "Start node not found.");
91 return;
92 }
93
94 auto node = gGeoManager->GetCurrentNode();
95
97
98 if (egn == nullptr) {
99 Warning(kEH, "No matching nodes found.");
100 return;
101 }
102
103 egn->SaveExtract("test-extract.root", "AliSDD", kTRUE);
104}
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
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:208
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:252
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:100
Int_t GetNdaughters() const
Definition TGeoNode.h:92
TGeoNode * GetDaughter(Int_t ind) const
Definition TGeoNode.h:84
TGeoMedium * GetMedium() const
Definition TGeoVolume.h:176
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
Basic string class.
Definition TString.h:138