ROOT
master
Reference Guide
Loading...
Searching...
No Matches
pointset.C File Reference
Tutorials
»
Visualisation tutorials
»
Event display tutorials
Detailed Description
Demonstrates usage of class
TEvePointSet
.
#include <
TEveManager.h
>
#include <
TEvePointSet.h
>
#include <
TEveRGBAPalette.h
>
#include <
TColor.h
>
#include <
TRandom.h
>
#include <
TMath.h
>
TEvePointSet
*
pointset
(
Int_t
npoints
= 512,
TEveElement
*parent =
nullptr
)
{
TEveManager::Create
();
if
(!
gRandom
)
gRandom
=
new
TRandom
(0);
TRandom
&
r
= *
gRandom
;
Float_t
s = 100;
auto
ps =
new
TEvePointSet
();
ps->SetOwnIds(
kTRUE
);
for
(
Int_t
i = 0; i <
npoints
; i++) {
ps->SetNextPoint(
r
.Uniform(-s, s),
r
.Uniform(-s, s),
r
.Uniform(-s, s));
ps->SetPointId(
new
TNamed
(
Form
(
"Point %d"
, i),
""
));
}
ps->SetMarkerColor(
TMath::Nint
(
r
.Uniform(2, 9)));
ps->SetMarkerSize(
r
.Uniform(1, 2));
ps->SetMarkerStyle(4);
if
(parent) {
parent->AddElement(ps);
}
else
{
gEve
->
AddElement
(ps);
gEve
->
Redraw3D
();
}
return
ps;
}
TEvePointSet
*
pointset_hierarchy
(
Int_t
level = 3,
Int_t
nps
= 1,
Int_t
fac
= 2,
Int_t
npoints
= 512,
TEveElement
*parent =
nullptr
)
{
// This only works in compiled mode!
TEvePointSet
*ps =
nullptr
;
--level;
for
(
Int_t
i = 0; i <
nps
; ++i) {
printf
(
"level=%d nps=%d i=%d\n"
, level,
nps
, i);
ps =
pointset
(
npoints
, parent);
if
(level) {
pointset_hierarchy
(level,
nps
*
fac
,
fac
,
npoints
/
fac
, ps);
}
}
return
ps;
}
TEvePointSetArray
*
pointsetarray
()
{
TEveManager::Create
();
TRandom
r
(0);
auto
l
=
new
TEvePointSetArray
(
"TPC hits - Charge Slices"
,
""
);
l
->SetSourceCS(
TEvePointSelectorConsumer::kTVT_RPhiZ
);
l
->SetMarkerColor(3);
l
->SetMarkerStyle(4);
// antialiased circle
l
->SetMarkerSize(0.8);
gEve
->
AddElement
(
l
);
l
->InitBins(
"Charge"
, 9, 10, 100);
TColor::SetPalette
(1,
nullptr
);
// Spectrum palette
const
Int_t
nCol
=
TColor::GetNumberOfColors
();
for
(
Int_t
i = 1; i <= 9; ++i)
l
->GetBin(i)->SetMainColor(
TColor::GetColorPalette
(i *
nCol
/ 10));
l
->GetBin(0)->SetMainColor(
kGray
);
l
->GetBin(10)->SetMainColor(
kWhite
);
Double_t
rad, phi, z;
for
(
Int_t
i = 0; i < 10000; ++i) {
rad =
r
.Uniform(60, 180);
phi =
r
.Uniform(0,
TMath::TwoPi
());
z =
r
.Uniform(-250, 250);
l
->Fill(rad *
TMath::Cos
(phi), rad *
TMath::Sin
(phi), z,
r
.Uniform(0, 110));
}
l
->CloseBins();
gEve
->
Redraw3D
();
return
l
;
}
Int_t
int Int_t
Definition
RtypesCore.h:45
Float_t
float Float_t
Definition
RtypesCore.h:57
Double_t
double Double_t
Definition
RtypesCore.h:59
kTRUE
constexpr Bool_t kTRUE
Definition
RtypesCore.h:93
kGray
@ kGray
Definition
Rtypes.h:65
kWhite
@ kWhite
Definition
Rtypes.h:65
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TColor.h
TEveManager.h
gEve
R__EXTERN TEveManager * gEve
Definition
TEveManager.h:243
TEvePointSet.h
TEveRGBAPalette.h
r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Definition
TGWin32VirtualXProxy.cxx:168
TMath.h
TRandom.h
gRandom
R__EXTERN TRandom * gRandom
Definition
TRandom.h:62
Form
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition
TString.cxx:2489
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TColor::SetPalette
static void SetPalette(Int_t ncolors, Int_t *colors, Float_t alpha=1.)
Static function.
Definition
TColor.cxx:2929
TColor::GetColorPalette
static Int_t GetColorPalette(Int_t i)
Static function returning the color number i in current palette.
Definition
TColor.cxx:1508
TColor::GetNumberOfColors
static Int_t GetNumberOfColors()
Static function returning number of colors in the color palette.
Definition
TColor.cxx:1528
TEveElement
Base class for TEveUtil visualization elements, providing hierarchy management, rendering control and...
Definition
TEveElement.h:36
TEveManager::AddElement
void AddElement(TEveElement *element, TEveElement *parent=nullptr)
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:887
TEveManager::Redraw3D
void Redraw3D(Bool_t resetCameras=kFALSE, Bool_t dropLogicals=kFALSE)
Definition
TEveManager.h:168
TEvePointSelectorConsumer::kTVT_RPhiZ
@ kTVT_RPhiZ
Definition
TEveTreeTools.h:48
TEvePointSetArray
An array of point-sets with each point-set playing a role of a bin in a histogram.
Definition
TEvePointSet.h:111
TEvePointSet
TEvePointSet is a render-element holding a collection of 3D points with optional per-point TRef and a...
Definition
TEvePointSet.h:36
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition
TNamed.h:29
TRandom
This is the base class for the ROOT Random number generators.
Definition
TRandom.h:27
TMath::Nint
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition
TMath.h:697
TMath::Cos
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition
TMath.h:598
TMath::Sin
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition
TMath.h:592
TMath::TwoPi
constexpr Double_t TwoPi()
Definition
TMath.h:44
l
TLine l
Definition
textangle.C:4
Author
Matevz Tadel
Definition in file
pointset.C
.
tutorials
visualisation
eve
pointset.C
ROOT master - Reference Guide Generated on Fri Jan 24 2025 04:37:32 (GVA Time) using Doxygen 1.10.0