ROOT
v6-26
Reference Guide
Loading...
Searching...
No Matches
quadset.C File Reference
Tutorials
»
Event display tutorials
Detailed Description
Demonstates usage of 2D digit class
TEveQuadSet
.
void
quadset_callback(
TEveDigitSet
* ds,
Int_t
idx,
TObject
* obj);
TString
quadset_tooltip_callback(
TEveDigitSet
* ds,
Int_t
idx);
void
quadset_set_callback(
TEveDigitSet
* ds);
//------------------------------------------------------------------------------
TEveQuadSet
* quadset(
Float_t
x
=0,
Float_t
y
=0,
Float_t
z=0,
Int_t
num=100,
Bool_t
registerSet=
kTRUE
)
{
TEveManager::Create
();
TRandom
r
(0);
TEveRGBAPalette
*pal =
new
TEveRGBAPalette
(0, 130);
TEveFrameBox
*
box
=
new
TEveFrameBox
();
box
->SetAAQuadXY(-10, -10, 0, 20, 20);
box
->SetFrameColor(
kGray
);
TEveQuadSet
*
q
=
new
TEveQuadSet
(
"RectangleXY"
);
q
->SetOwnIds(
kTRUE
);
q
->SetPalette(pal);
q
->SetFrame(
box
);
q
->Reset(
TEveQuadSet::kQT_RectangleXY
,
kFALSE
, 32);
for
(
Int_t
i=0; i<num; ++i)
{
q
->AddQuad(
r
.Uniform(-10, 9),
r
.Uniform(-10, 9), 0,
r
.Uniform(0.2, 1),
r
.Uniform(0.2, 1));
q
->QuadValue(
r
.Uniform(0, 130));
q
->QuadId(
new
TNamed
(
Form
(
"QuadIdx %d"
, i),
"TNamed assigned to a quad as an indentifier."
));
}
q
->RefitPlex();
TEveTrans
& t =
q
->RefMainTrans();
t.
RotateLF
(1, 3, 0.5*
TMath::Pi
());
t.
SetPos
(
x
,
y
, z);
TGLViewer
*
v
=
gEve
->
GetDefaultGLViewer
();
v
->
SetCurrentCamera
(
TGLViewer::kCameraOrthoZOY
);
TGLCameraOverlay
* co =
v
->GetCameraOverlay();
co->
SetShowOrthographic
(
kTRUE
);
co->
SetOrthographicMode
(
TGLCameraOverlay::kGridFront
);
// Uncomment these two lines to get internal highlight / selection.
// q->SetPickable(1);
// q->SetAlwaysSecSelect(1);
TEveRGBAPaletteOverlay
*po =
new
TEveRGBAPaletteOverlay
(pal, 0.55, 0.1, 0.4, 0.05);
v
=
gEve
->
GetDefaultGLViewer
();
v
->
AddOverlayElement
(po);
// To set user-interface (GUI + overlay) to display real values
// mapped with a linear function: r = 0.1 * i + 0;
// pal->SetUIDoubleRep(kTRUE, 0.1, 0);
if
(registerSet)
{
gEve
->
AddElement
(
q
);
gEve
->
Redraw3D
(
kTRUE
);
}
Info
(
"quadset"
,
"use alt-left-mouse to select individual digits."
);
return
q
;
}
TEveQuadSet
* quadset_emc(
Float_t
x
=0,
Float_t
y
=0,
Float_t
z=0,
Int_t
num=100)
{
TEveManager::Create
();
TRandom
r
(0);
TEveQuadSet
*
q
=
new
TEveQuadSet
(
"EMC Supermodule"
);
q
->SetOwnIds(
kTRUE
);
q
->Reset(
TEveQuadSet::kQT_RectangleXZFixedDimY
,
kFALSE
, 32);
q
->SetDefWidth(8);
q
->SetDefHeight(8);
for
(
Int_t
i=0; i<num; ++i)
{
q
->AddQuad(
r
.Uniform(-100, 100),
r
.Uniform(-100, 100));
q
->QuadValue(
r
.Uniform(0, 130));
q
->QuadId(
new
TNamed
(
Form
(
"Cell %d"
, i),
"Dong!"
));
}
q
->RefitPlex();
TEveTrans
& t =
q
->RefMainTrans();
t.
SetPos
(
x
,
y
, z);
gEve
->
AddElement
(
q
);
gEve
->
Redraw3D
();
return
q
;
}
TEveQuadSet
* quadset_circ()
{
TEveManager::Create
();
TRandom
rnd(0);
Float_t
R
= 10, dW = 1, dH = .5;
TEveFrameBox
*
box
=
new
TEveFrameBox
();
{
Float_t
frame[3*36];
Float_t
*p = frame;
for
(
Int_t
i = 0; i < 36; ++i, p += 3) {
p[0] = 11 *
TMath::Cos
(
TMath::TwoPi
()*i/36);
p[1] = 11 *
TMath::Sin
(
TMath::TwoPi
()*i/36);
p[2] = 0;
}
box
->SetQuadByPoints(frame, 36);
}
box
->SetFrameColor(
kGray
);
TEveQuadSet
*
q
=
new
TEveQuadSet
(
"Pepe"
);
q
->SetFrame(
box
);
q
->Reset(
TEveQuadSet::kQT_HexagonXY
,
kFALSE
, 32);
for
(
Float_t
r
=
R
;
r
> 2;
r
*= 0.8)
{
Int_t
maxI = 2.0*
TMath::Pi
()*
r
/ 2;
for
(
Int_t
i = 0; i < maxI; ++i)
{
Float_t
x
=
r
*
TMath::Cos
(
TMath::TwoPi
()*i/maxI);
Float_t
y
=
r
*
TMath::Sin
(
TMath::TwoPi
()*i/maxI);
q
->AddHexagon(
x
,
y
, rnd.Uniform(-1, 1), rnd.Uniform(0.2, 1));
q
->QuadValue(rnd.Uniform(0, 130));
}
}
q
->RefitPlex();
TEveTrans
& t =
q
->RefMainTrans();
t.
RotateLF
(1, 3, 0.5*
TMath::Pi
());
gEve
->
AddElement
(
q
);
gEve
->
Redraw3D
();
return
q
;
}
TEveQuadSet
* quadset_hex(
Float_t
x
=0,
Float_t
y
=0,
Float_t
z=0,
Int_t
num=100,
Bool_t
registerSet=
kTRUE
)
{
TEveManager::Create
();
TRandom
r
(0);
{
TEveQuadSet
*
q
=
new
TEveQuadSet
(
"HexagonXY"
);
q
->Reset(
TEveQuadSet::kQT_HexagonXY
,
kFALSE
, 32);
for
(
Int_t
i=0; i<num; ++i)
{
q
->AddHexagon(
r
.Uniform(-10, 10),
r
.Uniform(-10, 10),
r
.Uniform(-10, 10),
r
.Uniform(0.2, 1));
q
->QuadValue(
r
.Uniform(0, 120));
}
q
->RefitPlex();
TEveTrans
& t =
q
->RefMainTrans();
t.
SetPos
(
x
,
y
, z);
if
(registerSet)
{
gEve
->
AddElement
(
q
);
gEve
->
Redraw3D
();
}
}
{
TEveQuadSet
*
q
=
new
TEveQuadSet
(
"HexagonYX"
);
q
->Reset(
TEveQuadSet::kQT_HexagonYX
,
kFALSE
, 32);
for
(
Int_t
i=0; i<num; ++i)
{
q
->AddHexagon(
r
.Uniform(-10, 10),
r
.Uniform(-10, 10),
r
.Uniform(-10, 10),
r
.Uniform(0.2, 1));
q
->QuadValue(
r
.Uniform(0, 120));
}
q
->RefitPlex();
TEveTrans
& t =
q
->RefMainTrans();
t.
SetPos
(
x
,
y
, z);
if
(registerSet)
{
gEve
->
AddElement
(
q
);
gEve
->
Redraw3D
();
}
return
q
;
}
}
TEveQuadSet
* quadset_hexid(
Float_t
x
=0,
Float_t
y
=0,
Float_t
z=0,
Int_t
num=100,
Bool_t
registerSet=
kTRUE
)
{
TEveManager::Create
();
TRandom
r
(0);
TEveQuadSet
*
q
=
new
TEveQuadSet
(
"HexagonXY"
);
{
q
->SetOwnIds(
kTRUE
);
q
->Reset(
TEveQuadSet::kQT_HexagonXY
,
kFALSE
, 32);
for
(
Int_t
i=0; i<num; ++i)
{
q
->AddHexagon(
r
.Uniform(-10, 10),
r
.Uniform(-10, 10),
r
.Uniform(-10, 10),
r
.Uniform(0.2, 1));
q
->QuadValue(
r
.Uniform(0, 120));
q
->QuadId(
new
TNamed
(
Form
(
"Quad with idx=%d"
, i),
"This title is not confusing."
));
}
q
->RefitPlex();
TEveTrans
& t =
q
->RefMainTrans();
t.
SetPos
(
x
,
y
, z);
if
(registerSet)
{
gEve
->
AddElement
(
q
);
gEve
->
Redraw3D
();
}
}
quadset_set_callback(
q
);
// With the following you get per digit highlight with tooltip.
//q->SetPickable(1);
//q->SetAlwaysSecSelect(1);
// Otherwise you need to Alt - left click to get info printout.
return
q
;
}
void
quadset_hierarchy(
Int_t
n
=4)
{
TEveManager::Create
();
TEveRGBAPalette
* pal =
new
TEveRGBAPalette
(20, 100);
pal->
SetLimits
(0, 120);
TEveFrameBox
*
box
=
new
TEveFrameBox
();
box
->SetAABox(-10, -10, -10, 20, 20, 20);
box
->SetFrameColor(33);
TEveElementList
*
l
=
new
TEveElementList
(
"Parent/Dir"
);
l
->SetTitle(
"Tooltip"
);
// l->SetMainColor(3);
gEve
->
AddElement
(
l
);
for
(
Int_t
i=0; i<
n
; ++i)
{
TEveQuadSet
* qs = quadset_hexid(0, 0, 50*i, 50,
kFALSE
);
qs->
SetPalette
(pal);
qs->
SetFrame
(
box
);
l
->AddElement(qs);
}
gEve
->
Redraw3D
();
}
//------------------------------------------------------------------------------
void
quadset_callback(
TEveDigitSet
* ds,
Int_t
idx,
TObject
* obj)
{
printf(
"dump_digit_set_hit - 0x%lx, id=%d, obj=0x%lx\n"
,
(
ULong_t
) ds, idx, (
ULong_t
) obj);
}
TString
quadset_tooltip_callback(
TEveDigitSet
* ds,
Int_t
idx)
{
// This gets called for tooltip if the following is set:
// q->SetPickable(1);
// q->SetAlwaysSecSelect(1);
return
TString::Format
(
"callback tooltip for '%s' - 0x%lx, id=%d\n"
,
ds->
GetElementName
(), (
ULong_t
) ds, idx);
}
void
quadset_set_callback(
TEveDigitSet
* ds)
{
ds->
SetCallbackFoo
(quadset_callback);
ds->
SetTooltipCBFoo
(quadset_tooltip_callback);
}
r
ROOT::R::TRInterface & r
Definition
Object.C:4
Int_t
int Int_t
Definition
RtypesCore.h:45
kFALSE
const Bool_t kFALSE
Definition
RtypesCore.h:101
ULong_t
unsigned long ULong_t
Definition
RtypesCore.h:55
Bool_t
bool Bool_t
Definition
RtypesCore.h:63
Float_t
float Float_t
Definition
RtypesCore.h:57
kTRUE
const Bool_t kTRUE
Definition
RtypesCore.h:100
kGray
@ kGray
Definition
Rtypes.h:65
Info
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition
TError.cxx:220
gEve
R__EXTERN TEveManager * gEve
Definition
TEveManager.h:243
q
float * q
Definition
THbookFile.cxx:89
Form
char * Form(const char *fmt,...)
R
TEveDigitSet
Base-class for storage of digit collections; provides transformation matrix (TEveTrans),...
Definition
TEveDigitSet.h:34
TEveDigitSet::SetPalette
void SetPalette(TEveRGBAPalette *p)
Set TEveRGBAPalette pointer.
Definition
TEveDigitSet.cxx:441
TEveDigitSet::SetCallbackFoo
void SetCallbackFoo(Callback_foo f)
Definition
TEveDigitSet.h:176
TEveDigitSet::SetTooltipCBFoo
void SetTooltipCBFoo(TooltipCB_foo f)
Definition
TEveDigitSet.h:179
TEveDigitSet::SetFrame
void SetFrame(TEveFrameBox *b)
Set TEveFrameBox pointer.
Definition
TEveDigitSet.cxx:423
TEveElementList
A list of TEveElements.
Definition
TEveElement.h:433
TEveElement::GetElementName
virtual const char * GetElementName() const
Virtual function for retrieving name of the element.
Definition
TEveElement.cxx:265
TEveFrameBox
Description of a 2D or 3D frame that can be used to visually group a set of objects.
Definition
TEveFrameBox.h:19
TEveManager::AddElement
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
Definition
TEveManager.cxx:527
TEveManager::GetDefaultGLViewer
TGLViewer * GetDefaultGLViewer() const
Get TGLViewer of the default TEveViewer.
Definition
TEveManager.cxx:265
TEveManager::Create
static TEveManager * Create(Bool_t map_window=kTRUE, Option_t *opt="FIV")
If global TEveManager* gEve is not set initialize it.
Definition
TEveManager.cxx:892
TEveManager::Redraw3D
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition
TEveManager.h:168
TEveQuadSet
Supports various internal formats that result in rendering of a set of planar (lines,...
Definition
TEveQuadSet.h:20
TEveQuadSet::kQT_RectangleXY
@ kQT_RectangleXY
Definition
TEveQuadSet.h:30
TEveQuadSet::kQT_RectangleXZFixedDimY
@ kQT_RectangleXZFixedDimY
Definition
TEveQuadSet.h:38
TEveQuadSet::kQT_HexagonYX
@ kQT_HexagonYX
Definition
TEveQuadSet.h:47
TEveQuadSet::kQT_HexagonXY
@ kQT_HexagonXY
Definition
TEveQuadSet.h:46
TEveRGBAPaletteOverlay
Description of TEveRGBAPaletteOverlay.
Definition
TEveRGBAPaletteOverlay.h:22
TEveRGBAPalette
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Definition
TEveRGBAPalette.h:25
TEveRGBAPalette::SetLimits
void SetLimits(Int_t low, Int_t high)
Set low/high limits on signal value.
Definition
TEveRGBAPalette.cxx:165
TEveTrans
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition
TEveTrans.h:27
TEveTrans::RotateLF
void RotateLF(Int_t i1, Int_t i2, Double_t amount)
Rotate in local frame. Does optimised version of MultRight.
Definition
TEveTrans.cxx:374
TEveTrans::SetPos
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition
TEveTrans.cxx:506
TGLCameraOverlay
A GL overlay element which displays camera furstum.
Definition
TGLCameraOverlay.h:26
TGLCameraOverlay::SetShowOrthographic
void SetShowOrthographic(Bool_t x)
Definition
TGLCameraOverlay.h:73
TGLCameraOverlay::SetOrthographicMode
void SetOrthographicMode(EMode m)
Definition
TGLCameraOverlay.h:70
TGLCameraOverlay::kGridFront
@ kGridFront
Definition
TGLCameraOverlay.h:28
TGLViewerBase::AddOverlayElement
virtual void AddOverlayElement(TGLOverlayElement *el)
Add overlay element.
Definition
TGLViewerBase.cxx:211
TGLViewer
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition
TGLViewer.h:55
TGLViewer::SetCurrentCamera
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ,...
Definition
TGLViewer.cxx:1791
TGLViewer::kCameraOrthoZOY
@ kCameraOrthoZOY
Definition
TGLViewer.h:62
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition
TNamed.h:29
TObject
Mother of all ROOT objects.
Definition
TObject.h:41
TRandom
This is the base class for the ROOT Random number generators.
Definition
TRandom.h:27
TString
Basic string class.
Definition
TString.h:136
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition
TString.cxx:2336
box
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition
fillpatterns.C:1
y
Double_t y[n]
Definition
legend1.C:17
x
Double_t x[n]
Definition
legend1.C:17
n
const Int_t n
Definition
legend1.C:16
TMath::Cos
Double_t Cos(Double_t)
Definition
TMath.h:593
TMath::Pi
constexpr Double_t Pi()
Definition
TMath.h:37
TMath::Sin
Double_t Sin(Double_t)
Definition
TMath.h:589
TMath::TwoPi
constexpr Double_t TwoPi()
Definition
TMath.h:44
v
@ v
Definition
rootcling_impl.cxx:3670
l
auto * l
Definition
textangle.C:4
Author
Matevz Tadel
Definition in file
quadset.C
.
tutorials
eve
quadset.C
ROOT v6-26 - Reference Guide Generated on Mon Sep 11 2023 21:03:20 (GVA Time) using Doxygen 1.9.8