Logo ROOT   6.10/09
Reference Guide
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 
20 void 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");
27  TEveGeoTopNode* its = new TEveGeoTopNode(gGeoManager, node);
28  gEve->AddGlobalElement(its);
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 
51 TEveGeoNode* 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  TGeoMedium *medium = node->GetVolume()->GetMedium();
62  if (medium && material == medium->GetName())
63  {
64  // Node of interest - instantiate eve representation and return.
65  res = new TEveGeoNode(node);
66  return res;
67  }
68 
69  Int_t nd = node->GetNdaughters();
70  for (Int_t i = 0; i < nd; ++i)
71  {
72  TEveGeoNode *ed = descend_extract(node->GetDaughter(i));
73 
74  if (ed)
75  {
76  if (res == 0) res = new TEveGeoNode(node);
77  res->AddElement(ed);
78  }
79  }
80 
81  return res;
82 }
83 
84 void extract_ssd_modules()
85 {
86  const TString kEH("extract_ssd_modules");
87 
89 
90  gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/alice.root");
91 
92  Bool_t s = gGeoManager->cd("/ITSV_1/ITSD_1/IT56_1");
93  if (!s) {
94  Error(kEH, "Start node not found.");
95  return;
96  }
97 
99 
100  TEveGeoNode *egn = descend_extract(node);
101 
102  if (egn == 0)
103  {
104  Warning(kEH, "No matching nodes found.");
105  return;
106  }
107 
108  egn->SaveExtract("test-extract.root", "AliSDD", kTRUE);
109 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
void SaveExtract(const char *file, const char *name, Bool_t leafs_only)
Save the shape tree as TEveGeoShapeExtract.
void AddGlobalElement(TEveElement *element, TEveElement *parent=0)
Add a global element, i.e.
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition: TEveManager.h:168
Wrapper for TGeoNode that allows it to be shown in GUI and controlled as a TEveElement.
Definition: TEveGeoNode.h:31
TGeoMedium * GetMedium() const
Definition: TGeoVolume.h:176
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
TGeoNode * GetCurrentNode() const
Definition: TGeoManager.h:483
void Error(const char *location, const char *msgfmt,...)
A wrapper over a TGeoNode, possibly displaced with a global trasformation stored in TEveElement...
Definition: TEveGeoNode.h:92
TGeoManager * GetGeometry(const TString &filename)
Get geometry with given filename.
TGeoNode * GetDaughter(Int_t ind) const
Definition: TGeoNode.h:82
R__EXTERN TEveManager * gEve
Definition: TEveManager.h:243
virtual void AddElement(TEveElement *el)
Add el to the list of children.
void Warning(const char *location, const char *msgfmt,...)
virtual Bool_t cd(const char *path="")
Browse the tree of nodes starting from fTopNode according to pathname.
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:553
Media are used to store properties related to tracking and which are useful only when using geometry ...
Definition: TGeoMedium.h:23
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition: TGeoNode.h:39
Int_t GetNdaughters() const
Definition: TGeoNode.h:90
TGeoVolume * GetTopVolume() const
Definition: TGeoManager.h:496
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
TGeoVolume * GetVolume() const
Definition: TGeoNode.h:94