Logo ROOT  
Reference Guide
show_extract.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve7
3/// Helper script for showing of extracted / simplified geometries.
4/// By default shows a simplified ALICE geometry.
5///
6/// \image html eve_show_extract.png
7/// \macro_code
8///
9/// \author Matevz Tadel
10
11#include "TFile.h"
12#include "TKey.h"
13
14#include "TGeoShape.h"
15
16#include <ROOT/REveManager.hxx>
18#include <ROOT/REveGeoShape.hxx>
19
20namespace REX = ROOT::Experimental;
21
22void show_extract(const char* file="csg.root")
23{
24 // disable browser cache - all scripts and html files will be loaded every time, useful for development
25 // gEnv->SetValue("WebGui.HttpMaxAge", 0);
26
28
30
31 TIter next(gDirectory->GetListOfKeys());
32
33 const TString extract_class("ROOT::Experimental::REveGeoShapeExtract");
34
35 REX::REveGeoShape *eve_shape = nullptr;
36
37 while (auto key = (TKey *)next())
38 {
39 if (extract_class == key->GetClassName())
40 {
41 auto gse = (REX::REveGeoShapeExtract*) key->ReadObj();
42 eve_shape = REX::REveGeoShape::ImportShapeExtract(gse, 0);
43 eveMng->AddGlobalElement(eve_shape);
44 }
45 }
46
47 if (!eve_shape)
48 {
49 Error("show_extract.C", "No keys of class '%s'.", extract_class.Data());
50 return;
51 }
52
53 eve_shape->GetShape()->Draw("ogl");
54}
#define gDirectory
Definition: TDirectory.h:229
void Error(const char *location, const char *msgfmt,...)
static REveGeoShape * ImportShapeExtract(REveGeoShapeExtract *gse, REveElement *parent=nullptr)
Import a shape extract 'gse' under element 'parent'.
static REveManager * Create()
If global REveManager* REX::gEve is not set initialize it.
void AddGlobalElement(REveElement *element, REveElement *parent=nullptr)
Add a global element, i.e.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3942
virtual void Draw(Option_t *option="")
Draw this shape.
Definition: TGeoShape.cxx:721
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:28
Basic string class.
Definition: TString.h:131
REX::REveManager * eveMng
Definition: file.py:1