Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
projection_prescale.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve
3/// Demonstrates usage pre-scaling for automatic 2D projections.
4///
5/// \image html eve_projection_prescale.png
6/// \macro_code
7///
8/// \author Matevz Tadel
9
10const char *esd_geom_file_name = "http://root.cern/files/alice_ESDgeometry.root";
11
13{
16
17 auto pev = gEve->SpawnNewViewer("Projections");
18
19 // camera
20 auto s = gEve->SpawnNewScene("Projected Geom");
21 pev->AddScene(s);
22
23 auto pgv = pev->GetGLViewer();
24 pgv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
25 TGLOrthoCamera &cam = (TGLOrthoCamera &)pgv->CurrentCamera();
26 cam.SetZoomMinMax(0.2, 20);
27
28 // projections
29 auto mng = new TEveProjectionManager();
30 {
31 mng->SetProjection(TEveProjection::kPT_RPhi);
32 auto p = mng->GetProjection();
33 p->AddPreScaleEntry(0, 0, 4); // r scale 4 from 0
34 p->AddPreScaleEntry(0, 45, 1); // r scale 1 from 45
35 p->AddPreScaleEntry(0, 310, 0.5);
36 p->SetUsePreScale(kTRUE);
37 }
38 {
39 mng->SetProjection(TEveProjection::kPT_RhoZ);
40 auto p = mng->GetProjection();
41 // Increase silicon tracker
42 p->AddPreScaleEntry(0, 0, 4); // rho scale 4 from 0
43 p->AddPreScaleEntry(1, 0, 4); // z scale 4 from 0
44 // Normal for TPC
45 p->AddPreScaleEntry(0, 45, 1); // rho scale 1 from 45
46 p->AddPreScaleEntry(1, 110, 1); // z scale 1 from 110
47 // Reduce the rest
48 p->AddPreScaleEntry(0, 310, 0.5);
49 p->AddPreScaleEntry(1, 250, 0.5);
50 p->SetUsePreScale(kTRUE);
51 }
52 mng->SetProjection(TEveProjection::kPT_RPhi);
53 s->AddElement(mng);
54
55 auto axes = new TEveProjectionAxes(mng);
56 s->AddElement(axes);
57 gEve->AddToListTree(axes, kTRUE);
58 gEve->AddToListTree(mng, kTRUE);
59
60 // Simple geometry
61 auto geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
62 if (!geom)
63 return;
64
65 auto gse = (TEveGeoShapeExtract *)geom->Get("Gentle");
66 auto gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
67 geom->Close();
68 delete geom;
69 gEve->AddGlobalElement(gsre);
70 mng->ImportElements(gsre);
71
72 auto line = new TEveLine;
73 line->SetMainColor(kGreen);
74 for (Int_t i = 0; i < 160; ++i)
75 line->SetNextPoint(120 * sin(0.2 * i), 120 * cos(0.2 * i), 80 - i);
76 gEve->AddElement(line);
77 mng->ImportElements(line);
78 line->SetRnrSelf(kFALSE);
79
80 //-------------------------------------------------------------------------
81 // Scaled 3D "projection"
82 //-------------------------------------------------------------------------
83
84 auto sev = gEve->SpawnNewViewer("Scaled 3D");
86 auto sp = smng->GetProjection();
87 sp->SetUsePreScale(kTRUE);
88 sp->AddPreScaleEntry(2, 0, 1);
89 sp->AddPreScaleEntry(2, 100, 0.2);
90
91 auto ss = gEve->SpawnNewScene("Scaled Geom");
92 sev->AddScene(ss);
93 ss->AddElement(smng);
94
95 smng->ImportElements(gsre);
96
97 //-------------------------------------------------------------------------
98
99 gEve->GetBrowser()->GetTabRight()->SetTab(1);
100
101 gEve->Redraw3D(kTRUE);
102}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
@ kGreen
Definition Rtypes.h:67
externTEveManager * gEve
Globally positioned TGeoShape with rendering attributes and an optional list of daughter shape-extrac...
static TEveGeoShape * ImportShapeExtract(TEveGeoShapeExtract *gse, TEveElement *parent=nullptr)
Import a shape extract 'gse' under element 'parent'.
An arbitrary polyline with fixed line and marker attributes.
Definition TEveLine.h:26
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Axes for non-linear projections.
Manager class for steering of projections and managing projected objects.
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
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4328
Orthographic projection camera.
void SetZoomMinMax(Double_t min, Double_t max)
@ kCameraOrthoXOY
Definition TGLViewer.h:62
TLine * line
void projection_prescale(std::string type="RPhi")
RVec< PromoteType< T > > cos(const RVec< T > &v)
Definition RVec.hxx:1848
RVec< PromoteType< T > > sin(const RVec< T > &v)
Definition RVec.hxx:1847