Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
error_ellipse.C
Go to the documentation of this file.
2#include <ROOT/REveScene.hxx>
3#include <ROOT/REveViewer.hxx>
6
7
8using namespace ROOT::Experimental;
9
10
11void makeTracks(int N_Tracks, REveElement* trackHolder, float* pos)
12{
13 TRandom &r = *gRandom;
14 auto prop = new REveTrackPropagator();
15 prop->SetMagFieldObj(new REveMagFieldDuo(5, 3.5, -2.0));
16 prop->SetMaxR(9);
17 prop->SetMaxZ(15);
18
19 double v = 0.1;
20 double m = 5;
21 for (int i = 0; i < N_Tracks; i++)
22 {
23 auto p = new TParticle();
24 int pdg = 11 * (r.Integer(2) > 0 ? 1 : -1);
25 p->SetPdgCode(pdg);
26 p->SetProductionVertex(r.Uniform(-v,v) + pos[0], r.Uniform(-v,v) + pos[1], r.Uniform(-v,v) + pos[2], 1);
27 p->SetMomentum(r.Uniform(-m,m), r.Uniform(-m,m), r.Uniform(-m,m)*r.Uniform(1, 3), 1);
28 auto track = new REveTrack(p, 1, prop);
29 track->MakeTrack();
30 track->SetMainColor(kBlue);
31 track->SetName(Form("Track_%d", i));
32 trackHolder->AddElement(track);
33 }
34}
35
36void makeProjected(REveElement* el, const char* pname, REveProjection::EPType_e t)
37{
39 auto eventScene = eveMng->SpawnNewScene(Form("%s Event Data", pname), pname);
40 auto mng = new REveProjectionManager();
41 mng->SetProjection(t);
42 mng->ImportElements(el, eventScene);
43 auto view = eveMng->SpawnNewViewer(pname);
44 view->AddScene(eventScene);
45}
46
48{
49 auto eveMng = REveManager::Create();
50 float pos[3] = {1.46589e-06,-1.30522e-05,-1.98267e-05};
51
52 // symnetric matrix
53 double a[16] = {1.46589e-01,-1.30522e-02,-1.98267e-02, 0,
54 -1.30522e-02, 4.22955e-02,-5.86628e-03, 0,
55 -1.98267e-02,-5.86628e-03, 2.12836e-01, 0,
56 0, 0, 0, 1};
57
58 REveTrans t;
59 t.SetFrom(a);
60 TMatrixDSym xxx(3);
61 for(int i = 0; i < 3; i++)
62 for(int j = 0; j < 3; j++)
63 {
64 xxx(i,j) = t(i+1,j+1);
65 }
66
67 TMatrixDEigen eig(xxx);
68 TVectorD xxxEig ( eig.GetEigenValues() );
69 xxxEig = xxxEig.Sqrt();
70
71 TMatrixD vecEig = eig.GetEigenVectors();
72 REveVector v[3]; int ei = 0;
73 for (int i = 0; i < 3; ++i)
74 {
75 v[i].Set(vecEig(0,i), vecEig(1,i), vecEig(2,i));
76 v[i] *= xxxEig(i);
77 }
79
80 REveEllipsoid* ellipse = new REveEllipsoid("VertexError");
81 ellipse->InitMainTrans();
82 ellipse->SetMainColor(kGreen + 10);
83 ellipse->SetLineWidth(2);
84 ellipse->SetBaseVectors(v[0], v[1], v[2]);
85 ellipse->Outline();
86 event->AddElement(ellipse);
87
88 auto ps = new REvePointSet("Vertices");
89 ps->SetMainColor(kYellow);
90 ps->SetNextPoint(pos[0], pos[1], pos[2]);
91 ps->SetMarkerStyle(4);
92 ps->SetMarkerSize(4);
93 float rng = 1;
94 for(int i=0; i < 6; ++i)
95 ps->SetNextPoint(i*(rng/3) - rng, 0, 0);
96 event->AddElement(ps);
97
98 auto trackHolder = new REveElement("Tracks");
99 eveMng->GetEventScene()->AddElement(trackHolder);
100 makeTracks(10, trackHolder, pos);
101
102 makeProjected(eveMng->GetEventScene(), "RPhi", REveProjection::kPT_RPhi);
103 makeProjected(eveMng->GetEventScene(), "RhoZ", REveProjection::kPT_RhoZ);
104 eveMng->Show();
105}
ROOT::R::TRInterface & r
Definition Object.C:4
#define a(i)
Definition RSha256.hxx:99
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
char * Form(const char *fmt,...)
virtual void AddElement(REveElement *el)
Add el to the list of children.
virtual void InitMainTrans(Bool_t can_edit=kTRUE)
Initialize the main transformation to identity matrix.
virtual void SetMainColor(Color_t color)
Set main color of the element.
void SetBaseVectors(REveVector &v0, REveVector &v1, REveVector &v3)
Three defining base vectors of ellipse.
virtual void Outline()
Draw archade around base vectors.
REveMagFieldDuo Interface to magnetic field with two different values depending on radius.
REveScene * GetEventScene() const
REveScene * SpawnNewScene(const char *name, const char *title="")
Create a new scene.
REveViewer * SpawnNewViewer(const char *name, const char *title="")
Create a new GL viewer.
void Show(const RWebDisplayArgs &args="")
Show eve manager in specified browser.
REveProjectionManager Manager class for steering of projections and managing projected objects.
REveTrackPropagator Calculates path of a particle taking into account special path-marks and imposed ...
REveTrack Track with given vertex, momentum and optional referece-points (path-marks) along its path.
Definition REveTrack.hxx:40
void SetFrom(Double_t *carr)
void Set(const Float_t *v)
virtual void AddScene(REveScene *scene)
Add 'scene' to the list of scenes.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:43
TMatrixDEigen.
const TMatrixD & GetEigenVectors() const
const TMatrixD GetEigenValues() const
Computes the block diagonal eigenvalue matrix.
Description of the dynamic properties of a particle.
Definition TParticle.h:26
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
TVectorT< Element > & Sqrt()
Take square root of all elements.
Definition TVectorT.cxx:500
ROOT::Experimental::REveManager * eveMng
void error_ellipse()
void makeProjected(REveElement *el, const char *pname, REveProjection::EPType_e t)
void makeTracks(int N_Tracks, REveElement *trackHolder, float *pos)
R__EXTERN REveManager * gEve
auto * m
Definition textangle.C:8