Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
show_extract.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve_7
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
29 TFile::Open(file);
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 if (extract_class == key->GetClassName()) {
39 auto gse = (REX::REveGeoShapeExtract *)key->ReadObj();
40 eve_shape = REX::REveGeoShape::ImportShapeExtract(gse, nullptr);
41 eveMng->AddGlobalElement(eve_shape);
42 }
43 }
44
45 if (!eve_shape) {
46 Error("show_extract.C", "No keys of class '%s'.", extract_class.Data());
47 return;
48 }
49
50 eve_shape->GetShape()->Draw("ogl");
51}
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define gDirectory
Definition TDirectory.h:385
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.
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:3787
void Draw(Option_t *option="") override
Draw this shape.
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:138
ROOT::Experimental::REveManager * eveMng
Namespace for ROOT features in testing.
Definition TROOT.h:100