ROOT
v6-24
Reference Guide
Loading...
Searching...
No Matches
boxset_cones.C File Reference
Tutorials
»
Event display tutorials
Detailed Description
Demonstrates usage of 'cone' mode in
TEveBoxSet
class.
TEveBoxSet
* boxset_cones(
Float_t
x
=0,
Float_t
y
=0,
Float_t
z=0,
Int_t
num=100,
Bool_t
register
=
kTRUE
)
{
TEveManager::Create
();
using namespace
TMath
;
auto
lines =
new
TEveStraightLineSet
(
"StraightLines"
);
lines->SetLineColor(
kYellow
);
lines->SetLineWidth(2);
TRandom
r
(0);
auto
pal =
new
TEveRGBAPalette
(0, 500);
auto
cones =
new
TEveBoxSet
(
"ConeSet"
);
cones->SetPalette(pal);
cones->Reset(
TEveBoxSet::kBT_Cone
,
kFALSE
, 64);
Float_t
a
= 40;
// max distance between cones
TEveVector
dir, pos;
Float_t
theta, phi, height, rad;
for
(
Int_t
i=0; i<num; ++i) {
theta =
r
.Uniform(0,
TMath::Pi
());
phi =
r
.Uniform (-
TMath::Pi
(),
TMath::Pi
());
height =
r
.Uniform(5, 15);
rad =
r
.Uniform(3, 5);
dir.
Set
(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta));
dir *= height;
pos.
Set
(
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
));
cones->AddCone(pos, dir, rad);
cones->DigitValue(
r
.Uniform(0, 500));
// draw axis line 30% longer than cone height
TEveVector
end = pos + dir*1.3f;
lines->AddLine(pos.
fX
, pos.
fY
, pos.
fZ
, end.
fX
, end.
fY
, end.
fZ
);
}
// by default cone cap not drawn
if
(
r
.Integer(2)>0) cones->SetDrawConeCap(
kTRUE
);
cones->RefitPlex();
TEveTrans
& t = cones->RefMainTrans();
t.
SetPos
(
x
,
y
, z);
gEve
->
AddElement
(cones);
gEve
->
AddElement
(lines);
gEve
->
Redraw3D
(
kTRUE
);
return
cones;
}
TEveBoxSet
* elliptic_boxset_cones(
Float_t
x
=0,
Float_t
y
=0,
Float_t
z=0,
Int_t
num=100,
Bool_t
register
=
kTRUE
)
{
TEveManager::Create
();
using namespace
TMath
;
TEveManager::Create
();
auto
lines =
new
TEveStraightLineSet
(
"StraightLines"
);
lines->SetLineColor(
kYellow
);
lines->SetLineWidth(2);
TRandom
r
(0);
auto
cones =
new
TEveBoxSet
(
"EllipticConeSet"
);
cones->Reset(
TEveBoxSet::kBT_EllipticCone
,
kTRUE
, 64);
cones->SetPickable(
kTRUE
);
Float_t
a
= 40;
// max distance between cones
TEveVector
dir, pos;
Float_t
theta, phi, height, rad;
for
(
Int_t
i=0; i<num; ++i) {
theta =
r
.Uniform(0,
TMath::Pi
());
phi =
r
.Uniform (-
TMath::Pi
(),
TMath::Pi
());
height =
r
.Uniform(5, 15);
rad =
r
.Uniform(3, 5);
dir.
Set
(
Cos
(phi)*
Cos
(theta),
Sin
(phi)*
Cos
(theta),
Sin
(theta));
dir *= height;
pos.
Set
(
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
),
r
.Uniform(-
a
,
a
));
cones->AddEllipticCone(pos, dir, rad, 0.5*rad,
r
.Uniform(0,360));
cones->DigitColor(
r
.Uniform(20, 255),
r
.Uniform(20, 255),
r
.Uniform(20, 255),
r
.Uniform(20, 255));
// draw axis line 30% longer than cone height
TEveVector
end = pos + dir*1.3f;
lines->AddLine(pos.
fX
, pos.
fY
, pos.
fZ
, end.
fX
, end.
fY
, end.
fZ
);
}
// by default cone cap not drawn
if
(
r
.Integer(2)>0) cones->SetDrawConeCap(
kTRUE
);
cones->RefitPlex();
TEveTrans
& t = cones->RefMainTrans();
t.
SetPos
(
x
,
y
, z);
gEve
->
AddElement
(cones);
gEve
->
AddElement
(lines);
gEve
->
Redraw3D
(
kTRUE
);
return
cones;
}
r
ROOT::R::TRInterface & r
Definition
Object.C:4
a
#define a(i)
Definition
RSha256.hxx:99
Int_t
int Int_t
Definition
RtypesCore.h:45
kFALSE
const Bool_t kFALSE
Definition
RtypesCore.h:92
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:91
kYellow
@ kYellow
Definition
Rtypes.h:66
gEve
R__EXTERN TEveManager * gEve
Definition
TEveManager.h:243
TEveBoxSet
Collection of 3D primitives (fixed-size boxes, boxes of different sizes, or arbitrary sexto-epipeds,...
Definition
TEveBoxSet.h:22
TEveBoxSet::kBT_EllipticCone
@ kBT_EllipticCone
Definition
TEveBoxSet.h:35
TEveBoxSet::kBT_Cone
@ kBT_Cone
Definition
TEveBoxSet.h:34
TEveManager::AddElement
void AddElement(TEveElement *element, TEveElement *parent=0)
Add an element.
Definition
TEveManager.cxx:527
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
TEveRGBAPalette
A generic, speed-optimised mapping from value to RGBA color supporting different wrapping and range t...
Definition
TEveRGBAPalette.h:25
TEveStraightLineSet
Set of straight lines with optional markers along the lines.
Definition
TEveStraightLineSet.h:39
TEveTrans
TEveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
Definition
TEveTrans.h:27
TEveTrans::SetPos
void SetPos(Double_t x, Double_t y, Double_t z)
Set position (base-vec 4).
Definition
TEveTrans.cxx:506
TEveVectorT< Float_t >
TEveVectorT::fY
TT fY
Definition
TEveVector.h:30
TEveVectorT::fX
TT fX
Definition
TEveVector.h:30
TEveVectorT::fZ
TT fZ
Definition
TEveVector.h:30
TEveVectorT::Set
void Set(const Float_t *v)
Definition
TEveVector.h:82
TRandom
This is the base class for the ROOT Random number generators.
Definition
TRandom.h:27
y
Double_t y[n]
Definition
legend1.C:17
x
Double_t x[n]
Definition
legend1.C:17
TMath
TMath.
Definition
TMathBase.h:35
TMath::Cos
Double_t Cos(Double_t)
Definition
TMath.h:643
TMath::Pi
constexpr Double_t Pi()
Definition
TMath.h:37
TMath::Sin
Double_t Sin(Double_t)
Definition
TMath.h:639
Author
Alja Mrak-Tadel
Definition in file
boxset_cones.C
.
tutorials
eve
boxset_cones.C
ROOT v6-24 - Reference Guide Generated on Tue Aug 22 2023 03:07:14 (GVA Time) using Doxygen 1.9.8