Logo ROOT   6.14/05
Reference Guide
pointset.C File Reference

Detailed Description

Demonstrates usage of class TEvePointSet.

eve_pointset.png
#include <TEveManager.h>
#include <TEvePointSet.h>
#include <TColor.h>
#include <TRandom.h>
#include <TMath.h>
TEvePointSet* pointset(Int_t npoints = 512, TEveElement* parent=0)
{
if (!gRandom)
gRandom = new TRandom(0);
Float_t s = 100;
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->SetMarkerSize(r.Uniform(1, 2));
if (parent)
{
parent->AddElement(ps);
}
else
{
}
return ps;
}
pointset_hierarchy(Int_t level=3, Int_t nps=1, Int_t fac=2,
Int_t npoints=512, TEveElement* parent=0)
{
// This only works in compiled mode!
TEvePointSet* ps = 0;
--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()
{
TRandom r(0);
TEvePointSetArray* l = new TEvePointSetArray("TPC hits - Charge Slices", "");
l->SetMarkerStyle(4); // antialiased circle
l->SetMarkerSize(0.8);
l->InitBins("Charge", 9, 10, 100);
TColor::SetPalette(1, 0); // Spectrum palette
for (Int_t i = 1; i <= 9; ++i)
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();
return l;
}
Author
Matevz Tadel

Definition in file pointset.C.