Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
geom_alice_its.C File Reference

Detailed Description

Shows geometry of ALICE ITS.

#include "TEveManager.h"
#include "TEveGeoNode.h"
#include "TGeoManager.h"
#include "TGeoNode.h"
#include "TGeoVolume.h"
#include "TGeoMedium.h"
#include "TString.h"
void geom_alice_its()
{
gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/alice.root");
TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("ITSV_1");
}
//==============================================================================
// Demonstrate extraction of volumes matching certain criteria.
//==============================================================================
// Should be run in compiled mode -- CINT has issues with recursion.
//
// 1. Creation:
// root
// .L geom_alice_its.C+
// extract_ssd_modules()
// .q
// This creates file "test-extract.root" in current dir.
//
// 2. Viewing:
// root
// .x show_extract.C("test-extract.root")
TEveGeoNode* descend_extract(TGeoNode* node)
{
// We only return something if:
// - this is a node of interest;
// - one of the daughters returns something of interest.
const TString material("ITS_SI$");
TEveGeoNode *res = 0;
auto medium = node->GetVolume()->GetMedium();
if (medium && material == medium->GetName()) {
// Node of interest - instantiate eve representation and return.
res = new TEveGeoNode(node);
return res;
}
Int_t nd = node->GetNdaughters();
for (Int_t i = 0; i < nd; ++i) {
auto ed = descend_extract(node->GetDaughter(i));
if (ed) {
if (res == 0) res = new TEveGeoNode(node);
res->AddElement(ed);
}
}
return res;
}
void extract_ssd_modules()
{
const TString kEH("extract_ssd_modules");
gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/alice.root");
Bool_t s = gGeoManager->cd("/ITSV_1/ITSD_1/IT56_1");
if (!s) {
Error(kEH, "Start node not found.");
return;
}
auto node = gGeoManager->GetCurrentNode();
TEveGeoNode *egn = descend_extract(node);
if (egn == 0) {
Warning(kEH, "No matching nodes found.");
return;
}
egn->SaveExtract("test-extract.root", "AliSDD", kTRUE);
}
int Int_t
Definition RtypesCore.h:45
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
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
Author
Matevz Tadel

Definition in file geom_alice_its.C.