Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
error_ellipse.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve_7
3///
4/// \macro_code
5///
6/// \author Alja Mrak-Tadel
7
9#include <ROOT/REveScene.hxx>
10#include <ROOT/REveViewer.hxx>
11#include <ROOT/REveManager.hxx>
12#include <ROOT/REvePointSet.hxx>
13
14using namespace ROOT::Experimental;
15
16void makeTracks(int N_Tracks, REveElement *trackHolder, float *pos)
17{
18 TRandom &r = *gRandom;
19 auto prop = new REveTrackPropagator();
20 prop->SetMagFieldObj(new REveMagFieldDuo(5, 3.5, -2.0));
21 prop->SetMaxR(9);
22 prop->SetMaxZ(15);
23
24 double v = 0.1;
25 double m = 5;
26 for (int i = 0; i < N_Tracks; i++) {
27 auto p = new TParticle();
28 int pdg = 11 * (r.Integer(2) > 0 ? 1 : -1);
29 p->SetPdgCode(pdg);
30 p->SetProductionVertex(r.Uniform(-v, v) + pos[0], r.Uniform(-v, v) + pos[1], r.Uniform(-v, v) + pos[2], 1);
31 p->SetMomentum(r.Uniform(-m, m), r.Uniform(-m, m), r.Uniform(-m, m) * r.Uniform(1, 3), 1);
32 auto track = new REveTrack(p, 1, prop);
33 track->MakeTrack();
34 track->SetMainColor(kBlue);
35 track->SetName(Form("Track_%d", i));
36 trackHolder->AddElement(track);
37 }
38}
39
41{
43 auto eventScene = eveMng->SpawnNewScene(Form("%s Event Data", pname), pname);
44 auto mng = new REveProjectionManager();
45 mng->SetProjection(t);
46 mng->ImportElements(el, eventScene);
47 auto view = eveMng->SpawnNewViewer(pname);
48 view->SetCameraType(REveViewer::kCameraOrthoXOY);
49 view->AddScene(eventScene);
50}
51
52void error_ellipse()
53{
54 auto eveMng = REveManager::Create();
55 float pos[3] = {1.46589e-06, -1.30522e-05, -1.98267e-05};
56
57 // symnetric matrix
58 double a[16] = {1.46589e-01,
59 -1.30522e-02,
60 -1.98267e-02,
61 0,
62 -1.30522e-02,
63 4.22955e-02,
64 -5.86628e-03,
65 0,
66 -1.98267e-02,
67 -5.86628e-03,
68 2.12836e-01,
69 0,
70 0,
71 0,
72 0,
73 1};
74
75 REveTrans t;
76 t.SetFrom(a);
78 for (int i = 0; i < 3; i++)
79 for (int j = 0; j < 3; j++) {
80 xxx(i, j) = t(i + 1, j + 1);
81 }
82
84 TVectorD xxxEig(eig.GetEigenValues());
85 xxxEig = xxxEig.Sqrt();
86
87 TMatrixD vecEig = eig.GetEigenVectors();
88 REveVector v[3];
89 int ei = 0;
90 for (int i = 0; i < 3; ++i) {
91 v[i].Set(vecEig(0, i), vecEig(1, i), vecEig(2, i));
92 v[i] *= xxxEig(i);
93 }
94 REveElement *event = eveMng->GetEventScene();
95
96 REveEllipsoid *ellipse = new REveEllipsoid("VertexError");
97 ellipse->InitMainTrans();
98 ellipse->SetMainColor(kGreen + 10);
99 ellipse->SetLineWidth(2);
100 ellipse->SetBaseVectors(v[0], v[1], v[2]);
101 ellipse->Outline();
102 event->AddElement(ellipse);
103
104 // add TGeoSphere
105 auto sph = new REveGeoShape("Sphere");
106 sph->SetShape(new TGeoSphere(0.99f, 1.f));
107 sph->SetMainColor(kGreen);
108 sph->SetMainTransparency(80);
109 sph->SetNSegments(80);
110
111 float m0 = v[0].Mag();
112 v[0].Normalize();
113 float m1 = v[1].Mag();
114 v[1].Normalize();
115 float m2 = v[2].Mag();
116 v[2].Normalize();
117
118 sph->InitMainTrans();
119 sph->RefMainTrans().SetBaseVec(1, v[0].fX, v[0].fY, v[0].fZ);
120 sph->RefMainTrans().SetBaseVec(2, v[1].fX, v[1].fY, v[1].fZ);
121 sph->RefMainTrans().SetBaseVec(3, v[2].fX, v[2].fY, v[2].fZ);
122 sph->RefMainTrans().SetScale(m0, m1, m2);
123 event->AddElement(sph);
124
125 auto ps = new REvePointSet("Vertices");
126 ps->SetMainColor(kYellow);
127 ps->SetNextPoint(pos[0], pos[1], pos[2]);
128 ps->SetMarkerStyle(4);
129 ps->SetMarkerSize(4);
130 float rng = 1;
131 for (int i = 0; i < 6; ++i)
132 ps->SetNextPoint(i * (rng / 3) - rng, 0, 0);
133 event->AddElement(ps);
134
135 auto trackHolder = new REveElement("Tracks");
136 eveMng->GetEventScene()->AddElement(trackHolder);
137 makeTracks(10, trackHolder, pos);
138
139 makeProjected(eveMng->GetEventScene(), "RPhi", REveProjection::kPT_RPhi);
140 makeProjected(eveMng->GetEventScene(), "RhoZ", REveProjection::kPT_RhoZ);
141 eveMng->Show();
142}
#define a(i)
Definition RSha256.hxx:99
@ kGreen
Definition Rtypes.h:67
@ kBlue
Definition Rtypes.h:67
@ kYellow
Definition Rtypes.h:67
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
winID h TVirtualViewer3D TVirtualGLPainter p
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
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
R__EXTERN TRandom * gRandom
Definition TRandom.h:73
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
Base class for REveUtil visualization elements, providing hierarchy management, rendering control and...
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
Implements constant magnetic filed that switches on given axial radius fR2 from vector fBIn to fBOut.
REvePointSet is a render-element holding a collection of 3D points with optional per-point TRef and a...
Manager class for steering of projections and managing projected objects.
Holding structure for a number of track rendering parameters.
Visual representation of a track.
REveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
TGeoSphere are not just balls having internal and external radii, but sectors of a sphere having defi...
Definition TGeoSphere.h:17
TMatrixDEigen.
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:28
Namespace for ROOT features in testing.
Definition TROOT.h:100
R__EXTERN REveManager * gEve
TMarker m
Definition textangle.C:8