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///
7#include <ROOT/REveScene.hxx>
8#include <ROOT/REveViewer.hxx>
10#include <ROOT/REvePointSet.hxx>
11
12using namespace ROOT::Experimental;
13
15{
16 TRandom &r = *gRandom;
17 auto prop = new REveTrackPropagator();
18 prop->SetMagFieldObj(new REveMagFieldDuo(5, 3.5, -2.0));
19 prop->SetMaxR(9);
20 prop->SetMaxZ(15);
21
22 double v = 0.1;
23 double m = 5;
24 for (int i = 0; i < N_Tracks; i++) {
25 auto p = new TParticle();
26 int pdg = 11 * (r.Integer(2) > 0 ? 1 : -1);
27 p->SetPdgCode(pdg);
28 p->SetProductionVertex(r.Uniform(-v, v) + pos[0], r.Uniform(-v, v) + pos[1], r.Uniform(-v, v) + pos[2], 1);
29 p->SetMomentum(r.Uniform(-m, m), r.Uniform(-m, m), r.Uniform(-m, m) * r.Uniform(1, 3), 1);
30 auto track = new REveTrack(p, 1, prop);
31 track->MakeTrack();
32 track->SetMainColor(kBlue);
33 track->SetName(Form("Track_%d", i));
34 trackHolder->AddElement(track);
35 }
36}
37
39{
41 auto eventScene = eveMng->SpawnNewScene(Form("%s Event Data", pname), pname);
42 auto mng = new REveProjectionManager();
43 mng->SetProjection(t);
44 mng->ImportElements(el, eventScene);
45 auto view = eveMng->SpawnNewViewer(pname);
46 view->SetCameraType(REveViewer::kCameraOrthoXOY);
47 view->AddScene(eventScene);
48}
49
51{
52 auto eveMng = REveManager::Create();
53 float pos[3] = {1.46589e-06, -1.30522e-05, -1.98267e-05};
54
55 // symnetric matrix
56 double a[16] = {1.46589e-01,
57 -1.30522e-02,
58 -1.98267e-02,
59 0,
60 -1.30522e-02,
61 4.22955e-02,
62 -5.86628e-03,
63 0,
64 -1.98267e-02,
65 -5.86628e-03,
66 2.12836e-01,
67 0,
68 0,
69 0,
70 0,
71 1};
72
73 REveTrans t;
74 t.SetFrom(a);
76 for (int i = 0; i < 3; i++)
77 for (int j = 0; j < 3; j++) {
78 xxx(i, j) = t(i + 1, j + 1);
79 }
80
82 TVectorD xxxEig(eig.GetEigenValues());
83 xxxEig = xxxEig.Sqrt();
84
85 TMatrixD vecEig = eig.GetEigenVectors();
86 REveVector v[3];
87 int ei = 0;
88 for (int i = 0; i < 3; ++i) {
89 v[i].Set(vecEig(0, i), vecEig(1, i), vecEig(2, i));
90 v[i] *= xxxEig(i);
91 }
93
94 REveEllipsoid *ellipse = new REveEllipsoid("VertexError");
95 ellipse->InitMainTrans();
96 ellipse->SetMainColor(kGreen + 10);
97 ellipse->SetLineWidth(2);
98 ellipse->SetBaseVectors(v[0], v[1], v[2]);
99 ellipse->Outline();
100 event->AddElement(ellipse);
101
102 // add TGeoSphere
103 auto sph = new REveGeoShape("Sphere");
104 sph->SetShape(new TGeoSphere(0.99f, 1.f));
105 sph->SetMainColor(kGreen);
106 sph->SetMainTransparency(80);
107 sph->SetNSegments(80);
108
109 float m0 = v[0].Mag();
110 v[0].Normalize();
111 float m1 = v[1].Mag();
112 v[1].Normalize();
113 float m2 = v[2].Mag();
114 v[2].Normalize();
115
116 sph->InitMainTrans();
117 sph->RefMainTrans().SetBaseVec(1, v[0].fX, v[0].fY, v[0].fZ);
118 sph->RefMainTrans().SetBaseVec(2, v[1].fX, v[1].fY, v[1].fZ);
119 sph->RefMainTrans().SetBaseVec(3, v[2].fX, v[2].fY, v[2].fZ);
120 sph->RefMainTrans().SetScale(m0, m1, m2);
121 event->AddElement(sph);
122
123 auto ps = new REvePointSet("Vertices");
124 ps->SetMainColor(kYellow);
125 ps->SetNextPoint(pos[0], pos[1], pos[2]);
126 ps->SetMarkerStyle(4);
127 ps->SetMarkerSize(4);
128 float rng = 1;
129 for (int i = 0; i < 6; ++i)
130 ps->SetNextPoint(i * (rng / 3) - rng, 0, 0);
131 event->AddElement(ps);
132
133 auto trackHolder = new REveElement("Tracks");
135 makeTracks(10, trackHolder, pos);
136
137 makeProjected(eveMng->GetEventScene(), "RPhi", REveProjection::kPT_RPhi);
138 makeProjected(eveMng->GetEventScene(), "RhoZ", REveProjection::kPT_RhoZ);
139 eveMng->Show();
140}
#define a(i)
Definition RSha256.hxx:99
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
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:62
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
virtual void AddElement(REveElement *el)
Add el to the list of children.
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 SetCameraType(ECameraType t)
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:27
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
TMarker m
Definition textangle.C:8